Skip to content

Commit

Permalink
[chore]: enable suite-extra-assert-call rule from testifylint (#5833)
Browse files Browse the repository at this point in the history
#### Description

Testifylint is a linter that provides best practices with the use of
testify.

This PR enables
[suite-extra-assert-call](https://github.com/Antonboom/testifylint?tab=readme-ov-file#suite-extra-assert-call)
rule from [testifylint](https://github.com/Antonboom/testifylint)

Signed-off-by: Matthieu MOREL <[email protected]>
  • Loading branch information
mmorel-35 authored Sep 23, 2024
1 parent 063239f commit 561bd49
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 46 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -313,4 +313,3 @@ linters-settings:
- go-require
- negative-positive
- require-error
- suite-extra-assert-call
22 changes: 11 additions & 11 deletions exporters/zipkin/internal/internaltest/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *EnvStoreTestSuite) Test_add() {
envStore.add(e)
envStore.add(e)

s.Assert().Len(envStore.store, 1)
s.Len(envStore.store, 1)
}

func (s *EnvStoreTestSuite) TestRecord() {
Expand Down Expand Up @@ -87,16 +87,16 @@ func (s *EnvStoreTestSuite) TestRecord() {
for _, tc := range testCases {
s.Run(tc.name, func() {
if tc.env.Exists {
s.Assert().NoError(os.Setenv(tc.env.Name, tc.env.Value))
s.NoError(os.Setenv(tc.env.Name, tc.env.Value))
}

envStore := newEnvStore()
envStore.Record(tc.env.Name)

s.Assert().Equal(tc.expectedEnvStore, envStore)
s.Equal(tc.expectedEnvStore, envStore)

if tc.env.Exists {
s.Assert().NoError(os.Unsetenv(tc.env.Name))
s.NoError(os.Unsetenv(tc.env.Name))
}
})
}
Expand Down Expand Up @@ -140,10 +140,10 @@ func (s *EnvStoreTestSuite) TestRestore() {

s.Require().NoError(os.Unsetenv(tc.env.Name))

s.Assert().NoError(envStore.Restore())
s.NoError(envStore.Restore())
v, exists := os.LookupEnv(tc.env.Name)
s.Assert().Equal(tc.expectedEnvValue, v)
s.Assert().Equal(tc.expectedEnvExists, exists)
s.Equal(tc.expectedEnvValue, v)
s.Equal(tc.expectedEnvExists, exists)

// Restore
s.Require().NoError(backup.Restore())
Expand Down Expand Up @@ -186,11 +186,11 @@ func (s *EnvStoreTestSuite) Test_setEnv() {

s.Require().NoError(os.Setenv(tc.key, "other value"))

s.Assert().NoError(envStore.setEnv(tc.key, tc.value))
s.Assert().Equal(tc.expectedEnvStore, envStore)
s.NoError(envStore.setEnv(tc.key, tc.value))
s.Equal(tc.expectedEnvStore, envStore)
v, exists := os.LookupEnv(tc.key)
s.Assert().Equal(tc.expectedEnvValue, v)
s.Assert().Equal(tc.expectedEnvExists, exists)
s.Equal(tc.expectedEnvValue, v)
s.Equal(tc.expectedEnvExists, exists)

// Restore
s.Require().NoError(backup.Restore())
Expand Down
22 changes: 11 additions & 11 deletions internal/internaltest/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *EnvStoreTestSuite) Test_add() {
envStore.add(e)
envStore.add(e)

s.Assert().Len(envStore.store, 1)
s.Len(envStore.store, 1)
}

func (s *EnvStoreTestSuite) TestRecord() {
Expand Down Expand Up @@ -87,16 +87,16 @@ func (s *EnvStoreTestSuite) TestRecord() {
for _, tc := range testCases {
s.Run(tc.name, func() {
if tc.env.Exists {
s.Assert().NoError(os.Setenv(tc.env.Name, tc.env.Value))
s.NoError(os.Setenv(tc.env.Name, tc.env.Value))
}

envStore := newEnvStore()
envStore.Record(tc.env.Name)

s.Assert().Equal(tc.expectedEnvStore, envStore)
s.Equal(tc.expectedEnvStore, envStore)

if tc.env.Exists {
s.Assert().NoError(os.Unsetenv(tc.env.Name))
s.NoError(os.Unsetenv(tc.env.Name))
}
})
}
Expand Down Expand Up @@ -140,10 +140,10 @@ func (s *EnvStoreTestSuite) TestRestore() {

s.Require().NoError(os.Unsetenv(tc.env.Name))

s.Assert().NoError(envStore.Restore())
s.NoError(envStore.Restore())
v, exists := os.LookupEnv(tc.env.Name)
s.Assert().Equal(tc.expectedEnvValue, v)
s.Assert().Equal(tc.expectedEnvExists, exists)
s.Equal(tc.expectedEnvValue, v)
s.Equal(tc.expectedEnvExists, exists)

// Restore
s.Require().NoError(backup.Restore())
Expand Down Expand Up @@ -186,11 +186,11 @@ func (s *EnvStoreTestSuite) Test_setEnv() {

s.Require().NoError(os.Setenv(tc.key, "other value"))

s.Assert().NoError(envStore.setEnv(tc.key, tc.value))
s.Assert().Equal(tc.expectedEnvStore, envStore)
s.NoError(envStore.setEnv(tc.key, tc.value))
s.Equal(tc.expectedEnvStore, envStore)
v, exists := os.LookupEnv(tc.key)
s.Assert().Equal(tc.expectedEnvValue, v)
s.Assert().Equal(tc.expectedEnvExists, exists)
s.Equal(tc.expectedEnvValue, v)
s.Equal(tc.expectedEnvExists, exists)

// Restore
s.Require().NoError(backup.Restore())
Expand Down
22 changes: 11 additions & 11 deletions internal/shared/internaltest/env_test.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *EnvStoreTestSuite) Test_add() {
envStore.add(e)
envStore.add(e)

s.Assert().Len(envStore.store, 1)
s.Len(envStore.store, 1)
}

func (s *EnvStoreTestSuite) TestRecord() {
Expand Down Expand Up @@ -87,16 +87,16 @@ func (s *EnvStoreTestSuite) TestRecord() {
for _, tc := range testCases {
s.Run(tc.name, func() {
if tc.env.Exists {
s.Assert().NoError(os.Setenv(tc.env.Name, tc.env.Value))
s.NoError(os.Setenv(tc.env.Name, tc.env.Value))
}

envStore := newEnvStore()
envStore.Record(tc.env.Name)

s.Assert().Equal(tc.expectedEnvStore, envStore)
s.Equal(tc.expectedEnvStore, envStore)

if tc.env.Exists {
s.Assert().NoError(os.Unsetenv(tc.env.Name))
s.NoError(os.Unsetenv(tc.env.Name))
}
})
}
Expand Down Expand Up @@ -140,10 +140,10 @@ func (s *EnvStoreTestSuite) TestRestore() {

s.Require().NoError(os.Unsetenv(tc.env.Name))

s.Assert().NoError(envStore.Restore())
s.NoError(envStore.Restore())
v, exists := os.LookupEnv(tc.env.Name)
s.Assert().Equal(tc.expectedEnvValue, v)
s.Assert().Equal(tc.expectedEnvExists, exists)
s.Equal(tc.expectedEnvValue, v)
s.Equal(tc.expectedEnvExists, exists)

// Restore
s.Require().NoError(backup.Restore())
Expand Down Expand Up @@ -186,11 +186,11 @@ func (s *EnvStoreTestSuite) Test_setEnv() {

s.Require().NoError(os.Setenv(tc.key, "other value"))

s.Assert().NoError(envStore.setEnv(tc.key, tc.value))
s.Assert().Equal(tc.expectedEnvStore, envStore)
s.NoError(envStore.setEnv(tc.key, tc.value))
s.Equal(tc.expectedEnvStore, envStore)
v, exists := os.LookupEnv(tc.key)
s.Assert().Equal(tc.expectedEnvValue, v)
s.Assert().Equal(tc.expectedEnvExists, exists)
s.Equal(tc.expectedEnvValue, v)
s.Equal(tc.expectedEnvExists, exists)

// Restore
s.Require().NoError(backup.Restore())
Expand Down
22 changes: 11 additions & 11 deletions sdk/internal/internaltest/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func (s *EnvStoreTestSuite) Test_add() {
envStore.add(e)
envStore.add(e)

s.Assert().Len(envStore.store, 1)
s.Len(envStore.store, 1)
}

func (s *EnvStoreTestSuite) TestRecord() {
Expand Down Expand Up @@ -87,16 +87,16 @@ func (s *EnvStoreTestSuite) TestRecord() {
for _, tc := range testCases {
s.Run(tc.name, func() {
if tc.env.Exists {
s.Assert().NoError(os.Setenv(tc.env.Name, tc.env.Value))
s.NoError(os.Setenv(tc.env.Name, tc.env.Value))
}

envStore := newEnvStore()
envStore.Record(tc.env.Name)

s.Assert().Equal(tc.expectedEnvStore, envStore)
s.Equal(tc.expectedEnvStore, envStore)

if tc.env.Exists {
s.Assert().NoError(os.Unsetenv(tc.env.Name))
s.NoError(os.Unsetenv(tc.env.Name))
}
})
}
Expand Down Expand Up @@ -140,10 +140,10 @@ func (s *EnvStoreTestSuite) TestRestore() {

s.Require().NoError(os.Unsetenv(tc.env.Name))

s.Assert().NoError(envStore.Restore())
s.NoError(envStore.Restore())
v, exists := os.LookupEnv(tc.env.Name)
s.Assert().Equal(tc.expectedEnvValue, v)
s.Assert().Equal(tc.expectedEnvExists, exists)
s.Equal(tc.expectedEnvValue, v)
s.Equal(tc.expectedEnvExists, exists)

// Restore
s.Require().NoError(backup.Restore())
Expand Down Expand Up @@ -186,11 +186,11 @@ func (s *EnvStoreTestSuite) Test_setEnv() {

s.Require().NoError(os.Setenv(tc.key, "other value"))

s.Assert().NoError(envStore.setEnv(tc.key, tc.value))
s.Assert().Equal(tc.expectedEnvStore, envStore)
s.NoError(envStore.setEnv(tc.key, tc.value))
s.Equal(tc.expectedEnvStore, envStore)
v, exists := os.LookupEnv(tc.key)
s.Assert().Equal(tc.expectedEnvValue, v)
s.Assert().Equal(tc.expectedEnvExists, exists)
s.Equal(tc.expectedEnvValue, v)
s.Equal(tc.expectedEnvExists, exists)

// Restore
s.Require().NoError(backup.Restore())
Expand Down
2 changes: 1 addition & 1 deletion sdk/metric/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (ts *readerTestSuite) TestShutdownBeforeRegister() {
func (ts *readerTestSuite) TestCollectNilResourceMetricError() {
ts.Reader = ts.Factory()
ctx := context.Background()
ts.Assert().Error(ts.Reader.Collect(ctx, nil))
ts.Error(ts.Reader.Collect(ctx, nil))
}

var testScopeMetricsA = metricdata.ScopeMetrics{
Expand Down

0 comments on commit 561bd49

Please sign in to comment.