MCPcopy Create free account
hub / github.com/baidu/EasyFaaS / TestStorePointerToStruct

Function TestStorePointerToStruct

pkg/util/cache/cache_test.go:153–171  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestStorePointerToStruct(t *testing.T) {
154 tc := New(DefaultExpiration, 0)
155 tc.Set("foo", &TestStruct{Num: 1}, DefaultExpiration)
156 x, found := tc.Get("foo")
157 if !found {
158 t.Fatal("*TestStruct was not found for foo")
159 }
160 foo := x.(*TestStruct)
161 foo.Num++
162
163 y, found := tc.Get("foo")
164 if !found {
165 t.Fatal("*TestStruct was not found for foo (second time)")
166 }
167 bar := y.(*TestStruct)
168 if bar.Num != 2 {
169 t.Fatal("TestStruct.Num is not 2")
170 }
171}
172
173func TestIncrementWithInt(t *testing.T) {
174 tc := New(DefaultExpiration, 0)

Callers

nothing calls this directly

Calls 3

NewFunction · 0.70
SetMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected