(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func 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 | } |
nothing calls this directly
no test coverage detected