mem test
This commit is contained in:
parent
4e37009599
commit
5ab5505d2b
|
@ -1,14 +1,45 @@
|
|||
package memory_test
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"go-mod.ewintr.nl/planner/item"
|
||||
"go-mod.ewintr.nl/planner/plan/storage/memory"
|
||||
)
|
||||
|
||||
func TestSync(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
mem := memory.NewSync()
|
||||
|
||||
t.Log("store")
|
||||
count := 3
|
||||
for i := 0; i < count; i++ {
|
||||
mem.Store(item.Item{
|
||||
ID: fmt.Sprintf("id-%d", i),
|
||||
})
|
||||
}
|
||||
|
||||
t.Log("find all")
|
||||
actItems, actErr := mem.FindAll()
|
||||
if actErr != nil {
|
||||
t.Errorf("exp nil, got %v", actErr)
|
||||
}
|
||||
if len(actItems) != count {
|
||||
t.Errorf("exp %v, got %v", count, len(actItems))
|
||||
}
|
||||
|
||||
t.Log("delete all")
|
||||
if err := mem.DeleteAll(); err != nil {
|
||||
t.Errorf("exp nil, got %v", err)
|
||||
}
|
||||
actItems, actErr = mem.FindAll()
|
||||
if actErr != nil {
|
||||
t.Errorf("exp nil, got %v", actErr)
|
||||
}
|
||||
if len(actItems) != 0 {
|
||||
t.Errorf("exp 0, got %v", len(actItems))
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue