Skip to content

Commit

Permalink
Use shorter syntnax for type assertion verification
Browse files Browse the repository at this point in the history
Signed-off-by: adeyemi <adeyemi.aladesawe@gmail.com>
  • Loading branch information
aladesawe committed Jan 27, 2025
1 parent 8b9f622 commit 66c71ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
5 changes: 2 additions & 3 deletions server/auth/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
"golang.org/x/crypto/bcrypt"
"google.golang.org/grpc/metadata"
Expand Down Expand Up @@ -117,9 +118,7 @@ func setupAuthStore(t *testing.T) (store *authStore, teardownfunc func(t *testin
// The UserAdd function cannot generate old etcd version user data (user's option is nil)
// add special users through the underlying interface
asImpl, ok := as.(*authStore)
if !ok {
t.Fatal(errors.New("addUserWithNoOption: needs an AuthStore implementation"))
}
require.Truef(t, ok, "addUserWithNoOption: needs an AuthStore implementation")
addUserWithNoOption(asImpl)

tearDown := func(_ *testing.T) {
Expand Down
9 changes: 2 additions & 7 deletions server/storage/mvcc/watchable_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package mvcc

import (
"errors"
"fmt"
"reflect"
"sync"
Expand Down Expand Up @@ -342,9 +341,7 @@ func TestWatchNoEventLossOnCompact(t *testing.T) {
}
// fill up w.Chan() with 1 buf via 2 compacted watch response
sImpl, ok := s.(*watchableStore)
if !ok {
t.Fatal(errors.New("TestWatchNoEventLossOnCompact: needs a WatchableKV implementation"))
}
require.Truef(t, ok, "TestWatchNoEventLossOnCompact: needs a WatchableKV implementation")
sImpl.syncWatchers([]mvccpb.Event{})

for len(watchers) > 0 {
Expand Down Expand Up @@ -572,9 +569,7 @@ func TestWatchBatchUnsynced(t *testing.T) {
assert.Equal(t, tc.expectRevisionBatches, revisionBatches)

sImpl, ok := s.(*watchableStore)
if !ok {
t.Fatal(errors.New("TestWatchBatchUnsynced: needs a WatchableKV implementation"))
}
require.Truef(t, ok, "TestWatchBatchUnsynced: needs a WatchableKV implementation")

sImpl.store.revMu.Lock()
defer sImpl.store.revMu.Unlock()
Expand Down

0 comments on commit 66c71ea

Please sign in to comment.