Skip to content

Commit

Permalink
Merge pull request #18827 from mmorel-35/testifylint/go-require
Browse files Browse the repository at this point in the history
fix: enable go-require rule from testifylint
  • Loading branch information
ahrtr authored Nov 6, 2024
2 parents bd88963 + 7e7b7d5 commit 22ce068
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 12 deletions.
3 changes: 2 additions & 1 deletion tests/common/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

clientv3 "go.etcd.io/etcd/client/v3"
Expand Down Expand Up @@ -110,7 +111,7 @@ func TestAuthGracefulDisable(t *testing.T) {
return
}
// the watcher should still work after reconnecting
require.NoErrorf(t, rootAuthClient.Put(ctx, "key", "value", config.PutOptions{}), "failed to put key value")
assert.NoErrorf(t, rootAuthClient.Put(ctx, "key", "value", config.PutOptions{}), "failed to put key value")
}()

wCtx, wCancel := context.WithCancel(ctx)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/corrupt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func testCtlV3ReadAfterWrite(t *testing.T, ops ...clientv3.OpOption) {
}

count++
require.Equal(t, "bar2", string(resp.Kvs[0].Value))
assert.Equal(t, "bar2", string(resp.Kvs[0].Value))
}
}()

Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/ctl_v3_member_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestCtlV3ConsistentMemberList(t *testing.T) {
}

merr := epc.Procs[0].Restart(ctx)
require.NoError(t, merr)
assert.NoError(t, merr)
epc.WaitLeader(t)

time.Sleep(100 * time.Millisecond)
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestCtlV3ConsistentMemberList(t *testing.T) {
}

count++
require.Len(t, mresp.Members, 1)
assert.Len(t, mresp.Members, 1)
}
}()

Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/v3_lease_no_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

clientv3 "go.etcd.io/etcd/client/v3"
Expand Down Expand Up @@ -106,7 +107,7 @@ func testLeaseRevokeIssue(t *testing.T, clusterSize int, connectToOneFollower bo
defer close(doneC)

respC, kerr := clientForKeepAlive.KeepAlive(ctx, leaseRsp.ID)
require.NoError(t, kerr)
assert.NoError(t, kerr)
// ensure we have received the first response from the server
<-respC
startC <- struct{}{}
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/watch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func testStartWatcherFromCompactedRevision(t *testing.T, performCompactOnTombsto
t.Logf("DELETE key=%s", key)

resp, derr := c.KV.Delete(ctx, key)
require.NoError(t, derr)
assert.NoError(t, derr)
respHeader = resp.Header

requestedValues = append(requestedValues, valueEvent{value: "", typ: mvccpb.DELETE})
Expand All @@ -396,7 +396,7 @@ func testStartWatcherFromCompactedRevision(t *testing.T, performCompactOnTombsto

t.Logf("PUT key=%s, val=%s", key, value)
resp, perr := c.KV.Put(ctx, key, value)
require.NoError(t, perr)
assert.NoError(t, perr)
respHeader = resp.Header

requestedValues = append(requestedValues, valueEvent{value: value, typ: mvccpb.PUT})
Expand All @@ -409,7 +409,7 @@ func testStartWatcherFromCompactedRevision(t *testing.T, performCompactOnTombsto

t.Logf("COMPACT rev=%d", lastRevision)
_, err = c.KV.Compact(ctx, lastRevision, clientv3.WithCompactPhysical())
require.NoError(t, err)
assert.NoError(t, err)
}
}
}()
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/zap_logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"go.etcd.io/etcd/tests/v3/framework/e2e"
Expand Down Expand Up @@ -130,7 +131,7 @@ func TestConnectionRejectMessage(t *testing.T) {
go func() {
startedCh <- struct{}{}
verr := e2e.WaitReadyExpectProc(context.TODO(), p, []string{tc.expectedErrMsg})
require.NoError(t, verr)
assert.NoError(t, verr)
doneCh <- struct{}{}
}()

Expand Down
2 changes: 1 addition & 1 deletion tests/framework/testutils/log_observer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestLogObserver_Expect(t *testing.T) {
defer close(resCh)

res, err := logOb.Expect(ctx, t.Name(), 2)
require.NoError(t, err)
assert.NoError(t, err)
resCh <- res
}()

Expand Down
2 changes: 0 additions & 2 deletions tools/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ linters-settings: # please keep this alphabetized
checks:
- ST1019 # Importing the same package multiple times.
testifylint:
disable:
- go-require
enable-all: true
formatter:
# Require f-assertions (e.g. assert.Equalf) if a message is passed to the assertion, even if
Expand Down

0 comments on commit 22ce068

Please sign in to comment.