Skip to content

Commit

Permalink
fix lint and coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Pro committed Oct 29, 2023
1 parent 147d3dd commit 381f692
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions kv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,19 @@ func TestKVError(t *testing.T) {
}
}

func TestKVListByPrefix2Error(t *testing.T) {
cache := &MockErrCache{}
kv := NewKV[string](cache)

kv.Set("e", "wat")
kv.Set("er", "wat")
kv.Set("err", "something")
_, err := kv.ListByPrefix("err")
if err == nil {
t.Fatalf("expected error, got nil")
}
}

// To check that the error is propagated correctly.
type MockErrCache struct{}

Expand Down Expand Up @@ -747,7 +760,7 @@ func FuzzKVSetListByPrefix(f *testing.F) {
func TestKVDelNoprefix(t *testing.T) {
kv := NewKV[string](NewMapCache[string, string]())
kv.Set("hu", "hu")
kv.Del("h")
_ = kv.Del("h")
res, err := kv.Get("hu")
if err != nil {
t.Errorf("unexpected error in Get: %v", err)
Expand Down Expand Up @@ -797,7 +810,8 @@ func FuzzMonkey(f *testing.F) {
kv.Set(cmd.key, cmd.key)
golden[cmd.key] = struct{}{}
} else if cmd.action == "Del" {
kv.Del(cmd.key)
// Since keys are random we expect a lot of Del to fail.
_ = kv.Del(cmd.key)
delete(golden, cmd.key)
}
}
Expand Down

0 comments on commit 381f692

Please sign in to comment.