Skip to content

Commit

Permalink
Return store.ErrNotFound to be consistent with other stores
Browse files Browse the repository at this point in the history
  • Loading branch information
aduffeck committed Jun 3, 2024
1 parent 94a49ba commit 73391e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion v4/store/nats-js-kv/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func (n *natsStore) mustGetBucket(kv *nats.KeyValueConfig) (nats.KeyValue, error
func (n *natsStore) getRecord(bucket nats.KeyValue, key string) (*store.Record, bool, error) {
obj, err := bucket.Get(key)
if errors.Is(err, nats.ErrKeyNotFound) {
return nil, false, nil
return nil, false, store.ErrNotFound
} else if err != nil {
return nil, false, errors.Wrap(err, "Failed to get object from bucket")
}
Expand Down
4 changes: 2 additions & 2 deletions v4/store/nats-js-kv/nats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func TestNats(t *testing.T) {

// Test reading non-existing key
r, err := s.Read("this-is-a-random-key")
if err != nil {
t.Fatal(err)
if err != store.ErrNotFound {
t.Errorf("Expected %# v, got %# v", store.ErrNotFound, err)
}
if len(r) > 0 {
t.Fatal("Lenth should be 0")
Expand Down

0 comments on commit 73391e5

Please sign in to comment.