Skip to content

Commit

Permalink
fixing tests linting
Browse files Browse the repository at this point in the history
  • Loading branch information
tbuchaillot committed Dec 30, 2022
1 parent c197a65 commit 680de0c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gateway/rpc_storage_handler_test.go
Expand Up @@ -322,8 +322,8 @@ func TestGetGroupLoginCallback(t *testing.T) {
}

fn := rpcListener.getGroupLoginCallback(tc.syncEnabled)
groupLogin := fn(tc.givenKey, tc.givenGroup).(apidef.GroupLoginRequest)

groupLogin, ok := fn(tc.givenKey, tc.givenGroup).(apidef.GroupLoginRequest)
assert.True(t, ok)
assert.Equal(t, tc.expectedCallbackResponse, groupLogin)
})
}
Expand Down
4 changes: 3 additions & 1 deletion rpc/synchronization_forcer.go
@@ -1,6 +1,8 @@
package rpc

import (
"errors"

"github.com/TykTechnologies/tyk/apidef"
"github.com/TykTechnologies/tyk/storage"
)
Expand All @@ -22,7 +24,7 @@ func (sf *SyncronizerForcer) GrouLoginCallback(userKey string, groupID string) i
shouldForce := false

_, err := sf.store.GetKey(groupID)
if err != nil && err == storage.ErrKeyNotFound {
if err != nil && errors.Is(err, storage.ErrKeyNotFound) {
shouldForce = true

err = sf.store.SetKey(groupID, "", 0)
Expand Down
6 changes: 4 additions & 2 deletions rpc/synchronization_forcer_test.go
Expand Up @@ -45,13 +45,15 @@ func TestGrouLoginCallback(t *testing.T) {
groupID := "group"

//first time, it should force since the group key doesn't exists
groupLogin := sf.GrouLoginCallback(key, groupID).(apidef.GroupLoginRequest)
groupLogin, ok := sf.GrouLoginCallback(key, groupID).(apidef.GroupLoginRequest)
assert.True(t, ok)
assert.Equal(t, true, groupLogin.ForceSync)
assert.Equal(t, key, groupLogin.UserKey)
assert.Equal(t, groupID, groupLogin.GroupID)

//second time, it shouldn't force since the group key already exists
groupLogin = sf.GrouLoginCallback(key, groupID).(apidef.GroupLoginRequest)
groupLogin, ok = sf.GrouLoginCallback(key, groupID).(apidef.GroupLoginRequest)
assert.True(t, ok)
assert.Equal(t, false, groupLogin.ForceSync)
assert.Equal(t, key, groupLogin.UserKey)
assert.Equal(t, groupID, groupLogin.GroupID)
Expand Down

0 comments on commit 680de0c

Please sign in to comment.