Skip to content

Commit c6b29ec

Browse files
committed
CHASM: add more function tests
1 parent 45000b8 commit c6b29ec

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

tests/chasm_test.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,86 @@ func (s *ChasmTestSuite) TestNewPayloadStore() {
6363
s.NoError(err)
6464
}
6565

66+
func (s *ChasmTestSuite) TestPayloadStore_UpdateComponent() {
67+
tv := testvars.New(s.T())
68+
69+
ctx, cancel := context.WithTimeout(context.Background(), chasmTestTimeout)
70+
defer cancel()
71+
72+
storeID := tv.Any().String()
73+
_, err := tests.NewPayloadStoreHandler(
74+
chasm.NewEngineContext(ctx, s.chasmEngine),
75+
tests.NewPayloadStoreRequest{
76+
NamespaceID: s.NamespaceID(),
77+
StoreID: storeID,
78+
},
79+
)
80+
s.NoError(err)
81+
82+
_, err = tests.AddPayloadHandler(
83+
chasm.NewEngineContext(ctx, s.chasmEngine),
84+
tests.AddPayloadRequest{
85+
NamespaceID: s.NamespaceID(),
86+
StoreID: storeID,
87+
PayloadKey: "key1",
88+
Payload: payload.EncodeString("value1"),
89+
},
90+
)
91+
s.NoError(err)
92+
93+
descResp, err := tests.DescribePayloadStoreHandler(
94+
chasm.NewEngineContext(ctx, s.chasmEngine),
95+
tests.DescribePayloadStoreRequest{
96+
NamespaceID: s.NamespaceID(),
97+
StoreID: storeID,
98+
},
99+
)
100+
s.NoError(err)
101+
s.Equal(int64(1), descResp.State.TotalCount)
102+
s.True(descResp.State.TotalSize > 0)
103+
}
104+
105+
func (s *ChasmTestSuite) TestPayloadStore_PureTask() {
106+
tv := testvars.New(s.T())
107+
108+
ctx, cancel := context.WithTimeout(context.Background(), chasmTestTimeout)
109+
defer cancel()
110+
111+
storeID := tv.Any().String()
112+
_, err := tests.NewPayloadStoreHandler(
113+
chasm.NewEngineContext(ctx, s.chasmEngine),
114+
tests.NewPayloadStoreRequest{
115+
NamespaceID: s.NamespaceID(),
116+
StoreID: storeID,
117+
},
118+
)
119+
s.NoError(err)
120+
121+
_, err = tests.AddPayloadHandler(
122+
chasm.NewEngineContext(ctx, s.chasmEngine),
123+
tests.AddPayloadRequest{
124+
NamespaceID: s.NamespaceID(),
125+
StoreID: storeID,
126+
PayloadKey: "key1",
127+
Payload: payload.EncodeString("value1"),
128+
TTL: 1 * time.Second,
129+
},
130+
)
131+
s.NoError(err)
132+
133+
s.Eventually(func() bool {
134+
descResp, err := tests.DescribePayloadStoreHandler(
135+
chasm.NewEngineContext(ctx, s.chasmEngine),
136+
tests.DescribePayloadStoreRequest{
137+
NamespaceID: s.NamespaceID(),
138+
StoreID: storeID,
139+
},
140+
)
141+
s.NoError(err)
142+
return descResp.State.TotalCount == 0
143+
}, 10*time.Second, 100*time.Millisecond)
144+
}
145+
66146
func (s *ChasmTestSuite) TestPayloadStoreVisibility() {
67147
tv := testvars.New(s.T())
68148

0 commit comments

Comments
 (0)