Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions internal/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,8 @@ func (s *Store) Lookup(key string) (string, bool) {
v, ok := s.data[key]
return v, ok
}

// Delete removes key from the store.
func (s *Store) Delete(key string) {
delete(s.data, key)
}
9 changes: 9 additions & 0 deletions internal/store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,12 @@ func TestSetRejectsEmptyKey(t *testing.T) {
t.Fatal("Set with empty key: want error")
}
}

func TestDeleteRemovesKey(t *testing.T) {
s := New()
_ = s.Set("k", "v")
s.Delete("k")
if _, ok := s.Lookup("k"); ok {
t.Fatal("Delete(k): key still present")
}
}