(t *testing.T)
| 561 | } |
| 562 | |
| 563 | func TestSharedState_UsesAppJSONCodec(t *testing.T) { |
| 564 | t.Parallel() |
| 565 | |
| 566 | encoderCalled := false |
| 567 | decoderCalled := false |
| 568 | |
| 569 | app := New(Config{ |
| 570 | SharedStorage: newSharedStateMemoryStorage(t), |
| 571 | JSONEncoder: func(_ any) ([]byte, error) { |
| 572 | encoderCalled = true |
| 573 | return json.Marshal(Map{"via": "custom-encoder"}) |
| 574 | }, |
| 575 | JSONDecoder: func(data []byte, out any) error { |
| 576 | decoderCalled = true |
| 577 | return json.Unmarshal(data, out) |
| 578 | }, |
| 579 | }) |
| 580 | |
| 581 | require.NoError(t, app.SharedState().SetJSON("codec", Map{"ignored": true}, time.Minute)) |
| 582 | |
| 583 | var out map[string]string |
| 584 | _, found, err := app.SharedState().GetJSON("codec", &out) |
| 585 | require.NoError(t, err) |
| 586 | require.True(t, found) |
| 587 | require.Equal(t, "custom-encoder", out["via"]) |
| 588 | require.True(t, encoderCalled) |
| 589 | require.True(t, decoderCalled) |
| 590 | } |
| 591 | |
| 592 | func TestSharedState_UsesAppMsgPackCodec(t *testing.T) { |
| 593 | t.Parallel() |
nothing calls this directly
no test coverage detected