(t *testing.T)
| 590 | } |
| 591 | |
| 592 | func TestSharedState_UsesAppMsgPackCodec(t *testing.T) { |
| 593 | t.Parallel() |
| 594 | |
| 595 | encoderCalled := false |
| 596 | decoderCalled := false |
| 597 | |
| 598 | app := New(Config{ |
| 599 | SharedStorage: newSharedStateMemoryStorage(t), |
| 600 | MsgPackEncoder: func(_ any) ([]byte, error) { |
| 601 | encoderCalled = true |
| 602 | return []byte("msgpack-payload"), nil |
| 603 | }, |
| 604 | MsgPackDecoder: func(data []byte, out any) error { |
| 605 | decoderCalled = true |
| 606 | ptr, ok := out.(*string) |
| 607 | if ok { |
| 608 | *ptr = string(data) |
| 609 | } |
| 610 | return nil |
| 611 | }, |
| 612 | }) |
| 613 | |
| 614 | require.NoError(t, app.SharedState().SetMsgPack("codec", Map{"ignored": true}, time.Minute)) |
| 615 | |
| 616 | var out string |
| 617 | raw, found, err := app.SharedState().GetMsgPack("codec", &out) |
| 618 | require.NoError(t, err) |
| 619 | require.True(t, found) |
| 620 | require.Equal(t, []byte("msgpack-payload"), raw) |
| 621 | require.Equal(t, "msgpack-payload", out) |
| 622 | require.True(t, encoderCalled) |
| 623 | require.True(t, decoderCalled) |
| 624 | } |
| 625 | |
| 626 | func TestSharedState_UnconfiguredCodecsReturnErrorInsteadOfPanic(t *testing.T) { |
| 627 | t.Parallel() |
nothing calls this directly
no test coverage detected