From 42417a0bff15dd3b33c2563ebd68e36acb496b21 Mon Sep 17 00:00:00 2001 From: Robert Lin Date: Tue, 12 Dec 2023 12:01:12 -0800 Subject: [PATCH] chore: remove gotest.tools/assert (#58899) We use github.com/stretchr/testify pretty much universally except for some odd edge cases. This makes VSCode turn up inconsistent package recommendations on auto-import. --- cmd/frontend/internal/auth/saml/BUILD.bazel | 2 +- cmd/frontend/internal/auth/saml/user_test.go | 4 ++-- .../internal/gitserverfs/BUILD.bazel | 2 +- cmd/gitserver/internal/gitserverfs/fs_test.go | 2 +- cmd/gitserver/internal/perforce/BUILD.bazel | 1 - cmd/gitserver/internal/perforce/util_test.go | 2 +- .../internal/events/BUILD.bazel | 2 +- .../internal/events/events_test.go | 2 +- go.mod | 1 - internal/auth/accessrequest/BUILD.bazel | 2 +- internal/auth/accessrequest/handlers_test.go | 2 +- internal/database/BUILD.bazel | 1 - internal/database/ownership_stats_test.go | 22 +++++++++---------- internal/extsvc/azuredevops/BUILD.bazel | 1 - internal/extsvc/azuredevops/client_test.go | 2 +- internal/scim/BUILD.bazel | 1 - internal/scim/init_test.go | 2 +- lib/go.mod | 1 - lib/go.sum | 2 -- lib/managedservicesplatform/go.sum | 1 - lib/pointers/BUILD.bazel | 2 +- lib/pointers/ptr_test.go | 2 +- monitoring/go.sum | 1 - 23 files changed, 25 insertions(+), 35 deletions(-) diff --git a/cmd/frontend/internal/auth/saml/BUILD.bazel b/cmd/frontend/internal/auth/saml/BUILD.bazel index 590a1ffaaeb..456fb3c9ddc 100644 --- a/cmd/frontend/internal/auth/saml/BUILD.bazel +++ b/cmd/frontend/internal/auth/saml/BUILD.bazel @@ -65,7 +65,7 @@ go_test( "@com_github_crewjam_saml_samlidp//:samlidp", "@com_github_russellhaering_gosaml2//:gosaml2", "@com_github_russellhaering_goxmldsig//:goxmldsig", + "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", - "@tools_gotest//assert", ], ) diff --git a/cmd/frontend/internal/auth/saml/user_test.go b/cmd/frontend/internal/auth/saml/user_test.go index 009f9732934..1d4d13fba23 100644 --- a/cmd/frontend/internal/auth/saml/user_test.go +++ b/cmd/frontend/internal/auth/saml/user_test.go @@ -11,8 +11,8 @@ import ( saml2 "github.com/russellhaering/gosaml2" dsig "github.com/russellhaering/goxmldsig" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gotest.tools/assert" "github.com/sourcegraph/sourcegraph/internal/extsvc" ) @@ -127,7 +127,7 @@ func TestGetPublicExternalAccountData(t *testing.T) { require.NoError(t, err) } - assert.DeepEqual(t, tc.expected, publicData) + assert.Equal(t, tc.expected, publicData) }) } } diff --git a/cmd/gitserver/internal/gitserverfs/BUILD.bazel b/cmd/gitserver/internal/gitserverfs/BUILD.bazel index 6c896c3060b..7ba80ac916e 100644 --- a/cmd/gitserver/internal/gitserverfs/BUILD.bazel +++ b/cmd/gitserver/internal/gitserverfs/BUILD.bazel @@ -37,7 +37,7 @@ go_test( "//internal/database/dbtest", "//internal/types", "@com_github_sourcegraph_log//logtest", + "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", - "@tools_gotest//assert", ], ) diff --git a/cmd/gitserver/internal/gitserverfs/fs_test.go b/cmd/gitserver/internal/gitserverfs/fs_test.go index e73b0754dcf..ba23a73d3b6 100644 --- a/cmd/gitserver/internal/gitserverfs/fs_test.go +++ b/cmd/gitserver/internal/gitserverfs/fs_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/sourcegraph/log/logtest" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gotest.tools/assert" "github.com/sourcegraph/sourcegraph/cmd/gitserver/internal/common" "github.com/sourcegraph/sourcegraph/internal/api" diff --git a/cmd/gitserver/internal/perforce/BUILD.bazel b/cmd/gitserver/internal/perforce/BUILD.bazel index 042f8dd8a4a..4a0c0a03bd3 100644 --- a/cmd/gitserver/internal/perforce/BUILD.bazel +++ b/cmd/gitserver/internal/perforce/BUILD.bazel @@ -64,6 +64,5 @@ go_test( "@com_github_sourcegraph_log//logtest", "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", - "@tools_gotest//assert", ], ) diff --git a/cmd/gitserver/internal/perforce/util_test.go b/cmd/gitserver/internal/perforce/util_test.go index 49adbef02ef..3576c805efb 100644 --- a/cmd/gitserver/internal/perforce/util_test.go +++ b/cmd/gitserver/internal/perforce/util_test.go @@ -4,7 +4,7 @@ import ( "os/exec" "testing" - "gotest.tools/assert" + "github.com/stretchr/testify/assert" ) func TestSpecifyCommandInErrorMessage(t *testing.T) { diff --git a/cmd/telemetry-gateway/internal/events/BUILD.bazel b/cmd/telemetry-gateway/internal/events/BUILD.bazel index 6108735d8a2..1be278c2148 100644 --- a/cmd/telemetry-gateway/internal/events/BUILD.bazel +++ b/cmd/telemetry-gateway/internal/events/BUILD.bazel @@ -22,7 +22,7 @@ go_test( ":events", "//internal/pubsub/pubsubtest", "//internal/telemetrygateway/v1:telemetrygateway", + "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", - "@tools_gotest//assert", ], ) diff --git a/cmd/telemetry-gateway/internal/events/events_test.go b/cmd/telemetry-gateway/internal/events/events_test.go index 9e2449cf6ed..2acfaaed287 100644 --- a/cmd/telemetry-gateway/internal/events/events_test.go +++ b/cmd/telemetry-gateway/internal/events/events_test.go @@ -8,8 +8,8 @@ import ( "testing" "time" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gotest.tools/assert" "github.com/sourcegraph/sourcegraph/cmd/telemetry-gateway/internal/events" "github.com/sourcegraph/sourcegraph/internal/pubsub/pubsubtest" diff --git a/go.mod b/go.mod index c0b390dd3d9..05ac22bd5de 100644 --- a/go.mod +++ b/go.mod @@ -605,7 +605,6 @@ require ( gopkg.in/square/go-jose.v2 v2.6.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect gorm.io/driver/postgres v1.5.4 - gotest.tools v2.2.0+incompatible k8s.io/klog/v2 v2.80.0 // indirect k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect mvdan.cc/gofumpt v0.4.0 // indirect diff --git a/internal/auth/accessrequest/BUILD.bazel b/internal/auth/accessrequest/BUILD.bazel index f5664d4d219..e8bbc640fbd 100644 --- a/internal/auth/accessrequest/BUILD.bazel +++ b/internal/auth/accessrequest/BUILD.bazel @@ -37,7 +37,7 @@ go_test( "//internal/types", "//schema", "@com_github_sourcegraph_log//logtest", + "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", - "@tools_gotest//assert", ], ) diff --git a/internal/auth/accessrequest/handlers_test.go b/internal/auth/accessrequest/handlers_test.go index 01df25610b0..da26a5b71a8 100644 --- a/internal/auth/accessrequest/handlers_test.go +++ b/internal/auth/accessrequest/handlers_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/sourcegraph/log/logtest" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gotest.tools/assert" "github.com/sourcegraph/sourcegraph/internal/conf" "github.com/sourcegraph/sourcegraph/internal/database" diff --git a/internal/database/BUILD.bazel b/internal/database/BUILD.bazel index af660ac72b0..162afb07fe9 100644 --- a/internal/database/BUILD.bazel +++ b/internal/database/BUILD.bazel @@ -336,7 +336,6 @@ go_test( "@org_golang_x_exp//maps", "@org_golang_x_exp//slices", "@org_golang_x_sync//errgroup", - "@tools_gotest//assert", ], ) diff --git a/internal/database/ownership_stats_test.go b/internal/database/ownership_stats_test.go index ad836af4190..bd7ef4b301d 100644 --- a/internal/database/ownership_stats_test.go +++ b/internal/database/ownership_stats_test.go @@ -6,8 +6,8 @@ import ( "time" "github.com/sourcegraph/log/logtest" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gotest.tools/assert" "github.com/sourcegraph/sourcegraph/internal/database/dbtest" "github.com/sourcegraph/sourcegraph/internal/types" @@ -114,7 +114,7 @@ func TestQueryIndividualCountsAggregation(t *testing.T) { {CodeownersReference: "ownerA", CodeownedFileCount: 1}, {CodeownersReference: "ownerB", CodeownedFileCount: 1}, } - assert.DeepEqual(t, want, got) + assert.Equal(t, want, got) }) t.Run("query single repo", func(t *testing.T) { opts := TreeLocationOpts{ @@ -127,7 +127,7 @@ func TestQueryIndividualCountsAggregation(t *testing.T) { {CodeownersReference: "ownerA", CodeownedFileCount: 2}, {CodeownersReference: "ownerB", CodeownedFileCount: 1}, } - assert.DeepEqual(t, want, got) + assert.Equal(t, want, got) }) t.Run("query whole instance", func(t *testing.T) { opts := TreeLocationOpts{} @@ -139,7 +139,7 @@ func TestQueryIndividualCountsAggregation(t *testing.T) { {CodeownersReference: "ownerC", CodeownedFileCount: 10}, // only repo2 {CodeownersReference: "ownerB", CodeownedFileCount: 1}, // only repo1 } - assert.DeepEqual(t, want, got) + assert.Equal(t, want, got) }) } @@ -218,7 +218,7 @@ func TestQueryAggregateCounts(t *testing.T) { got, err := db.OwnershipStats().QueryAggregateCounts(ctx, opts) require.NoError(t, err) want := PathAggregateCounts{CodeownedFileCount: 0} - assert.DeepEqual(t, want, got) + assert.Equal(t, want, got) }) t.Run("no data - query all", func(t *testing.T) { @@ -226,7 +226,7 @@ func TestQueryAggregateCounts(t *testing.T) { got, err := db.OwnershipStats().QueryAggregateCounts(ctx, opts) require.NoError(t, err) want := PathAggregateCounts{CodeownedFileCount: 0} - assert.DeepEqual(t, want, got) + assert.Equal(t, want, got) }) // 2. Insert aggregate counts: @@ -275,7 +275,7 @@ func TestQueryAggregateCounts(t *testing.T) { TotalOwnedFileCount: 1, UpdatedAt: timestamp, } - assert.DeepEqual(t, want, got) + assert.Equal(t, want, got) }) t.Run("query single dir", func(t *testing.T) { @@ -291,7 +291,7 @@ func TestQueryAggregateCounts(t *testing.T) { TotalOwnedFileCount: 2, UpdatedAt: timestamp, } - assert.DeepEqual(t, want, got) + assert.Equal(t, want, got) }) t.Run("query repo root", func(t *testing.T) { @@ -306,7 +306,7 @@ func TestQueryAggregateCounts(t *testing.T) { TotalOwnedFileCount: 2, UpdatedAt: timestamp, } - assert.DeepEqual(t, want, got) + assert.Equal(t, want, got) }) t.Run("query whole instance", func(t *testing.T) { @@ -319,7 +319,7 @@ func TestQueryAggregateCounts(t *testing.T) { TotalOwnedFileCount: 12, UpdatedAt: timestamp, } - assert.DeepEqual(t, want, got) + assert.Equal(t, want, got) }) t.Run("query whole instance with excluded repo in signal config", func(t *testing.T) { @@ -334,6 +334,6 @@ func TestQueryAggregateCounts(t *testing.T) { TotalOwnedFileCount: 2, UpdatedAt: timestamp, } - assert.DeepEqual(t, want, got) + assert.Equal(t, want, got) }) } diff --git a/internal/extsvc/azuredevops/BUILD.bazel b/internal/extsvc/azuredevops/BUILD.bazel index a2691ed58ac..62253d85c06 100644 --- a/internal/extsvc/azuredevops/BUILD.bazel +++ b/internal/extsvc/azuredevops/BUILD.bazel @@ -57,6 +57,5 @@ go_test( "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", "@org_golang_x_time//rate", - "@tools_gotest//assert", ], ) diff --git a/internal/extsvc/azuredevops/client_test.go b/internal/extsvc/azuredevops/client_test.go index 05bb5c84c25..337c9d5de13 100644 --- a/internal/extsvc/azuredevops/client_test.go +++ b/internal/extsvc/azuredevops/client_test.go @@ -13,9 +13,9 @@ import ( "time" "github.com/dnaeon/go-vcr/cassette" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "golang.org/x/time/rate" - "gotest.tools/assert" "github.com/sourcegraph/sourcegraph/internal/extsvc/auth" "github.com/sourcegraph/sourcegraph/internal/httpcli" diff --git a/internal/scim/BUILD.bazel b/internal/scim/BUILD.bazel index f978aea58c9..f629b4e8414 100644 --- a/internal/scim/BUILD.bazel +++ b/internal/scim/BUILD.bazel @@ -74,6 +74,5 @@ go_test( "@com_github_elimity_com_scim//errors", "@com_github_scim2_filter_parser_v2//:filter-parser", "@com_github_stretchr_testify//assert", - "@tools_gotest//assert", ], ) diff --git a/internal/scim/init_test.go b/internal/scim/init_test.go index ea8fd3f594c..95f586de5fa 100644 --- a/internal/scim/init_test.go +++ b/internal/scim/init_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "gotest.tools/assert" + "github.com/stretchr/testify/assert" "github.com/sourcegraph/sourcegraph/internal/conf" "github.com/sourcegraph/sourcegraph/internal/database" diff --git a/lib/go.mod b/lib/go.mod index f858630252c..b84a6987d9c 100644 --- a/lib/go.mod +++ b/lib/go.mod @@ -37,7 +37,6 @@ require ( google.golang.org/protobuf v1.31.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 - gotest.tools v2.2.0+incompatible ) require ( diff --git a/lib/go.sum b/lib/go.sum index e4b4d5e3e05..04b772cd302 100644 --- a/lib/go.sum +++ b/lib/go.sum @@ -542,8 +542,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk= gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0= gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8= diff --git a/lib/managedservicesplatform/go.sum b/lib/managedservicesplatform/go.sum index 91923c8237e..be479b2e060 100644 --- a/lib/managedservicesplatform/go.sum +++ b/lib/managedservicesplatform/go.sum @@ -449,6 +449,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/lib/pointers/BUILD.bazel b/lib/pointers/BUILD.bazel index d7a7783f209..fe089db5602 100644 --- a/lib/pointers/BUILD.bazel +++ b/lib/pointers/BUILD.bazel @@ -13,7 +13,7 @@ go_test( srcs = ["ptr_test.go"], embed = [":pointers"], deps = [ + "@com_github_stretchr_testify//assert", "@com_github_stretchr_testify//require", - "@tools_gotest//assert", ], ) diff --git a/lib/pointers/ptr_test.go b/lib/pointers/ptr_test.go index ce9b54a3c43..41a02ba5f75 100644 --- a/lib/pointers/ptr_test.go +++ b/lib/pointers/ptr_test.go @@ -3,8 +3,8 @@ package pointers import ( "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "gotest.tools/assert" ) func TestPtr(t *testing.T) { diff --git a/monitoring/go.sum b/monitoring/go.sum index 2e5e2338991..41849c69548 100644 --- a/monitoring/go.sum +++ b/monitoring/go.sum @@ -642,7 +642,6 @@ gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=