MCPcopy Create free account
hub / github.com/conforma/cli / Test_Persist

Function Test_Persist

acceptance/testenv/testenv_test.go:165–197  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

163}
164
165func Test_Persist(t *testing.T) {
166 var persisted string
167 persister = func(filename string, data []byte, perm fs.FileMode) error {
168 persisted = string(data)
169 return nil
170 }
171
172 ctx := context.WithValue(context.TODO(), PersistStubEnvironment, true)
173 ctx = context.WithValue(ctx, persistedEnv, &map[string]any{
174 persistedKey(&stateful{}): &stateful{
175 Number: 42,
176 Str: "dogs",
177 },
178 persistedKey(&another{}): &another{
179 Val: 12,
180 },
181 })
182
183 persisting, err := Persist(ctx)
184
185 assert.True(t, persisting)
186 assert.NoError(t, err)
187
188 assert.JSONEq(t, `{
189 "testenv.key.0": {
190 "Number": 42,
191 "Str": "dogs"
192 },
193 "testenv.key.1": {
194 "Val": 12
195 }
196 }`, persisted)
197}
198
199func Test_PersistOff(t *testing.T) {
200 var persisted bool

Callers

nothing calls this directly

Calls 2

persistedKeyFunction · 0.85
PersistFunction · 0.85

Tested by

no test coverage detected