MCPcopy Create free account
hub / github.com/devld/go-drive / TestSharedStateRejectsNonJSONValues

Function TestSharedStateRejectsNonJSONValues

drive/script/shared_state_test.go:60–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

58}
59
60func TestSharedStateRejectsNonJSONValues(t *testing.T) {
61 for name, code := range map[string]string{
62 "function": `setData({state: function () {}})`,
63 "cycle": `var state = {}; state.self = state; setData({state: state})`,
64 } {
65 t.Run(name, func(t *testing.T) {
66 d := &ScriptDrive{data: make(map[string]json.RawMessage)}
67 vm := newSharedStateTestVM(t, d)
68
69 _, e := vm.Run(context.Background(), code)
70 if e == nil || !strings.Contains(e.Error(), "shared state must be JSON serializable") {
71 t.Fatalf("expected JSON serialization error, got %v", e)
72 }
73 })
74 }
75}

Callers

nothing calls this directly

Calls 3

newSharedStateTestVMFunction · 0.85
RunMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected