-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype_test.go
51 lines (43 loc) · 963 Bytes
/
type_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
51
package diderot
import (
"testing"
"time"
"github.com/linkedin/diderot/ads"
"github.com/linkedin/diderot/testutils"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/wrapperspb"
)
func TestType(t *testing.T) {
tests := []struct {
Name string
UseRawSetter bool
}{
{
Name: "typed",
UseRawSetter: false,
},
{
Name: "raw",
UseRawSetter: true,
},
}
for _, test := range tests {
t.Run(test.Name, func(t *testing.T) {
c := NewCache[*wrapperspb.BoolValue]()
const foo = "foo"
r := &ads.Resource[*wrapperspb.BoolValue]{
Name: foo,
Version: "0",
Resource: wrapperspb.Bool(true),
}
if test.UseRawSetter {
require.NoError(t, c.SetRaw(testutils.MustMarshal(t, r), time.Time{}))
} else {
c.SetResource(r, time.Time{})
}
testutils.ResourceEquals(t, r, c.Get(foo))
c.Clear(foo, time.Time{})
require.Nil(t, c.Get(foo))
})
}
}