diff --git a/Collection_test.go b/Collection_test.go index a1258b4..7e84cbf 100644 --- a/Collection_test.go +++ b/Collection_test.go @@ -11,7 +11,7 @@ type User struct { Name string `json:"name"` } -func TestCollectionGet(t *testing.T) { +func TestGet(t *testing.T) { users, err := ocean.New[User]("test") assert.Nil(t, err) defer users.Clear() @@ -23,6 +23,22 @@ func TestCollectionGet(t *testing.T) { assert.NotNil(t, user) } +func TestCollectionAll(t *testing.T) { + users, err := ocean.New[User]("test") + assert.Nil(t, err) + defer users.Clear() + + users.Set("1", &User{Name: "User 1"}) + users.Set("2", &User{Name: "User 2"}) + count := 0 + + for range users.All() { + count++ + } + + assert.Equal(t, count, 2) +} + func TestInteraction(t *testing.T) { users, err := ocean.New[User]("test") assert.Nil(t, err) @@ -52,18 +68,23 @@ func TestInteraction(t *testing.T) { assert.True(t, !users.Exists("2")) } -func TestCollectionAll(t *testing.T) { +func TestPersistence(t *testing.T) { users, err := ocean.New[User]("test") assert.Nil(t, err) defer users.Clear() users.Set("1", &User{Name: "User 1"}) users.Set("2", &User{Name: "User 2"}) - count := 0 - for range users.All() { - count++ - } + again, err := ocean.New[User]("test") + assert.Nil(t, err) - assert.Equal(t, count, 2) + user1, err := again.Get("1") + assert.Nil(t, err) + + user2, err := again.Get("2") + assert.Nil(t, err) + + assert.NotNil(t, user1) + assert.NotNil(t, user2) }