[GODRIVER-2179] Replace testutil/assert with testify/assert Created: 11/Oct/21  Updated: 24/Jan/23  Resolved: 30/Nov/22

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.12.0, 1.12.0-alpha1

Type: Improvement Priority: Major - P3
Reporter: Matt Dale Assignee: Benji Rewis (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Gantt Dependency
has to be done before GODRIVER-2667 Replace AssertSoon with Eventually Backlog
Epic Link: Improve Testing Suite
Quarter: FY23Q4

 Description   

The mongo-go-driver tests currently use a mixture of "go.mongodb.org/mongo-driver/internal/testutil/assert", "github.com/stretchr/testify/assert" to assert things in the tests. Those packages have a similar but slightly different API that is confusing to read/use together. The "github.com/stretchr/testify/assert" package is a more complete API and is a standard assertion API in Go projects, so prefer that package over the internal package.

Questions:

  • Is "github.com/stretchr/testify/assert" the best package or is there another package that has superseded it?

Definition of done:

  • Vendor a useful subset of the "github.com/stretchr/testify/assert" and "github.com/stretchr/testify/require" packages somewhere in an internal package.
  • Replace all uses of the "go.mongodb.org/mongo-driver/internal/testutil/assert" package with the vendored "github.com/stretchr/testify/assert"/"github.com/stretchr/testify/require" APIs.
  • Remove the testutil/assert package.


 Comments   
Comment by Githook User [ 30/Nov/22 ]

Author:

{'name': 'Benjamin Rewis', 'email': '32186188+benjirewis@users.noreply.github.com', 'username': 'benjirewis'}

Message: GODRIVER-2179 Unify testing API. (#1137)

  • Removes the testify dependency.
  • Removes the tidwall/pretty dependency.
  • Modifies the existing internal/assert package to be a copy of a subset of testify/assert and pmezard/go-difflib.
  • Adds a new internal/require package that is a copy of a subset of testify/require.
  • Changes all assert and require imports to refer to internal.
  • Runs go mod tidy and go mod vendor.
  • Fixes tests that relied on old test API behavior.
    Branch: master
    https://github.com/mongodb/mongo-go-driver/commit/977993fa81b76cdd599b59ac763ec85d15dbaa0e
Comment by Benji Rewis (Inactive) [ 21/Nov/22 ]

https://github.com/mongodb/mongo-go-driver/pull/1137

Generated at Thu Feb 08 08:37:59 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.