-
Notifications
You must be signed in to change notification settings - Fork 0
/
slice_test.go
44 lines (36 loc) · 884 Bytes
/
slice_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
package gowed_test
import (
"testing"
"github.com/redbirdztc/gowed"
"github.com/stretchr/testify/assert"
)
func TestExtracSliceUnexpiredData(t *testing.T) {
type ExpirableStruct struct {
gowed.Expirer
}
expirable := ExpirableStruct{
Expirer: Expired{},
}
unexpirable := ExpirableStruct{
Expirer: Unexpired{},
}
slice := []ExpirableStruct{unexpirable, expirable}
result := gowed.ExtracSliceUnexpiredData(slice)
assert.Len(t, result, 1)
assert.Equal(t, unexpirable, result[0])
}
func TestExtracSliceExpiredData(t *testing.T) {
type ExpirableStruct struct {
gowed.Expirer
}
expirable := ExpirableStruct{
Expirer: Expired{},
}
unexpirable := ExpirableStruct{
Expirer: Unexpired{},
}
slice := []ExpirableStruct{unexpirable, expirable}
result := gowed.ExtracSliceExpiredData(slice)
assert.Len(t, result, 1)
assert.Equal(t, expirable, result[0])
}