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

Function Test_SetupStateExistingValue

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

Source from the content-addressed store, hash-verified

98}
99
100func Test_SetupStateExistingValue(t *testing.T) {
101 existing := another{Val: 2.5}
102
103 ctx := context.WithValue(context.TODO(), persistedEnv, &map[string]any{
104 "testenv.key.1": &existing,
105 })
106
107 var s *stateful
108 ctx, err := SetupState(ctx, &s)
109
110 assert.NoError(t, err)
111
112 var a *another
113 ctx, err = SetupState(ctx, &a)
114
115 assert.NoError(t, err)
116
117 expectedStateful := stateful{Number: 0, Str: ""}
118 assert.Equal(t, expectedStateful, *s)
119 assert.Equal(t, &expectedStateful, FetchState[stateful](ctx))
120
121 expectedAnother := another{Val: 2.5}
122 assert.Equal(t, expectedAnother, *a)
123 assert.Equal(t, &expectedAnother, FetchState[another](ctx))
124}
125
126func Test_SetupStateMutateExistingValue(t *testing.T) {
127 var s1 *stateful

Callers

nothing calls this directly

Calls 1

SetupStateFunction · 0.85

Tested by

no test coverage detected