Skip to content

Commit

Permalink
add test for invalid key
Browse files Browse the repository at this point in the history
  • Loading branch information
corinapurcarea committed Aug 17, 2020
1 parent a7ab8a7 commit 9e5334e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions store/freecache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestFreecacheGetNotFound(t *testing.T) {
assert.Nil(t, value)
}

func TestFreecacheGetInvalidKey(t *testing.T) {
func TestFreecacheGetWithInvalidKey(t *testing.T) {
// Given
ctrl := gomock.NewController(t)
defer ctrl.Finish()
Expand All @@ -90,8 +90,9 @@ func TestFreecacheGetInvalidKey(t *testing.T) {

s := NewFreecache(client, nil)

_, err := s.Get([]byte("key1"))
value, err := s.Get([]byte("key1"))
assert.Error(t, err, "key type not supported by Freecache store")
assert.Nil(t, value)
}

func TestFreecacheGetWithTTL(t *testing.T) {
Expand Down Expand Up @@ -166,6 +167,21 @@ func TestFreecacheGetWithTTLWhenErrorAtTTL(t *testing.T) {
assert.Equal(t, 0*time.Second, ttl)
}

func TestFreecacheGetWithTTLWhenInvalidKey(t *testing.T) {
// Given
ctrl := gomock.NewController(t)
defer ctrl.Finish()

client := mocksStore.NewMockFreecacheClientInterface(ctrl)

s := NewFreecache(client, nil)

value, ttl, err := s.GetWithTTL([]byte("key1"))
assert.Error(t, err, "key type not supported by Freecache store")
assert.Nil(t, value)
assert.Equal(t, 0*time.Second, ttl)
}

func TestFreecacheSet(t *testing.T) {
// Given
ctrl := gomock.NewController(t)
Expand Down

0 comments on commit 9e5334e

Please sign in to comment.