-
Notifications
You must be signed in to change notification settings - Fork 0
/
table_delete_test.go
50 lines (43 loc) · 998 Bytes
/
table_delete_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package yti_test
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestDelete(t *testing.T) {
t.Run("delete on empty table", func(t *testing.T) {
t.Parallel()
table := InMemoryTable(t, nil)
table.Delete(func(item TestStruct) bool { return false })
assert.Equal(
t,
0,
table.Count(),
)
})
t.Run("delete - happy path", func(t *testing.T) {
t.Parallel()
table := InMemoryTable(t, nil)
assert.NoError(t, table.Insert(TestStruct{Id: 1}))
table.Delete(func(item TestStruct) bool { return item.Id == 1 })
assert.Equal(
t,
0,
table.Count(),
)
})
t.Run("delete - more than one item in the seed", func(t *testing.T) {
t.Parallel()
var expected = TestStruct{Id: 2, Name: "test"}
table := InMemoryPopulatedTable(
t,
[]TestStruct{{Id: 1, Name: "test"}, expected, {Id: 3, Name: "test"}},
nil,
)
table.Delete(func(item TestStruct) bool { return item.Id == expected.Id })
assert.Equal(
t,
2,
table.Count(),
)
})
}