Skip to content

Commit

Permalink
test: should expect exact error
Browse files Browse the repository at this point in the history
  • Loading branch information
Tuan Nguyen committed Apr 20, 2024
1 parent 36180e9 commit 3b0654c
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 128 deletions.
8 changes: 4 additions & 4 deletions cache/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func TestMemory_Get(t *testing.T) {
t.Run(testify.CaseKOKeyEmptyError, func(st *testing.T) {
var dest string
err := c.Get(context.Background(), "", &dest)
require.ErrorContains(t, err, "CACHE.KEY.EMPTY.ERROR")
require.ErrorIs(t, err, ErrKeyEmpty)
})

t.Run("KO - key not found error", func(st *testing.T) {
Expand Down Expand Up @@ -119,7 +119,7 @@ func TestMemory_Set(t *testing.T) {

t.Run(testify.CaseKOKeyEmptyError, func(st *testing.T) {
err := c.Set(context.Background(), "", value, ttl)
require.ErrorContains(st, err, "CACHE.KEY.EMPTY.ERROR")
require.ErrorIs(st, err, ErrKeyEmpty)
})

t.Run("KO - marshal error", func(st *testing.T) {
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestNenory_Del(t *testing.T) {

t.Run(testify.CaseKOKeyEmptyError, func(st *testing.T) {
err := c.Del(context.Background(), "")
require.ErrorContains(st, err, "CACHE.KEY.EMPTY.ERROR")
require.ErrorIs(st, err, ErrKeyEmpty)
})
}

Expand Down Expand Up @@ -213,7 +213,7 @@ func TestMemory_Expire(t *testing.T) {

t.Run(testify.CaseKOKeyEmptyError, func(st *testing.T) {
err := c.Expire(context.Background(), "", time.Now())
require.ErrorContains(st, err, "CACHE.KEY.EMPTY.ERROR")
require.ErrorIs(st, err, ErrKeyEmpty)
})

t.Run("KO - key not found error", func(st *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions cache/redis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestRedis_Get(t *testing.T) {
t.Run(testify.CaseKOKeyEmptyError, func(st *testing.T) {
var dest string
err := c.Get(context.Background(), "", &dest)
require.ErrorContains(st, err, "CACHE.KEY.EMPTY.ERROR")
require.ErrorIs(st, err, ErrKeyEmpty)
})

t.Run("KO - key not found error", func(st *testing.T) {
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestRedis_Set(t *testing.T) {

t.Run(testify.CaseKOKeyEmptyError, func(st *testing.T) {
err := c.Set(context.Background(), "", value, ttl)
require.ErrorContains(st, err, "CACHE.KEY.EMPTY.ERROR")
require.ErrorIs(st, err, ErrKeyEmpty)
})

t.Run("KO - marshal error", func(st *testing.T) {
Expand Down Expand Up @@ -185,7 +185,7 @@ func TestRedis_Delete(t *testing.T) {

t.Run(testify.CaseKOKeyEmptyError, func(st *testing.T) {
err := c.Del(context.Background(), "")
require.ErrorContains(st, err, "CACHE.KEY.EMPTY.ERROR")
require.ErrorIs(st, err, ErrKeyEmpty)
})
}

Expand Down Expand Up @@ -221,7 +221,7 @@ func TestRedis_Expire(t *testing.T) {

t.Run(testify.CaseKOKeyEmptyError, func(st *testing.T) {
err := c.Expire(context.Background(), "", time.Now())
require.ErrorContains(st, err, "CACHE.KEY.EMPTY.ERROR")
require.ErrorIs(st, err, ErrKeyEmpty)
})

t.Run("KO - key not found error", func(st *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion checksum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
67b50d794b73980250e7d8ec6d5e79ad57e37419c6ff2442d9b285bf704bfca1
fec5d643d6f56005aa62b7fa96e77b5fd8b2f4c18a0da2b88064d3852d997352
Loading

0 comments on commit 3b0654c

Please sign in to comment.