rewrite: storage tests

This commit is contained in:
Dimitry Kolyshev 2022-11-22 12:54:55 +02:00
parent 0a1ad86ea7
commit 941538abfe
1 changed files with 21 additions and 0 deletions

View File

@ -17,3 +17,24 @@ func TestNewDefaultStorage(t *testing.T) {
require.Equal(t, 1, len(s.List()))
}
func TestDefaultStorage_CRUD(t *testing.T) {
var items []*Item
s, err := NewDefaultStorage(-1, items)
require.NoError(t, err)
require.Equal(t, 0, len(s.List()))
item := &Item{Domain: "example.com", Answer: "answer.com"}
err = s.Add(item)
require.NoError(t, err)
list := s.List()
require.Equal(t, 1, len(list))
require.True(t, item.equal(list[0]))
err = s.Remove(item)
require.NoError(t, err)
require.Equal(t, 0, len(s.List()))
}