MCPcopy Index your code
hub / github.com/frain-dev/convoy / TestDecodeMsgPack

Function TestDecodeMsgPack

pkg/msgpack/msgpack_test.go:59–87  ·  view source on GitHub ↗

TestDecodeMsgPack verifies msgpack decoding functionality

(t *testing.T)

Source from the content-addressed store, hash-verified

57
58// TestDecodeMsgPack verifies msgpack decoding functionality
59func TestDecodeMsgPack(t *testing.T) {
60 type testStruct struct {
61 Name string `json:"name"`
62 Value int `json:"value"`
63 }
64
65 original := testStruct{
66 Name: "test",
67 Value: 42,
68 }
69
70 // Encode
71 encoded, err := EncodeMsgPack(original)
72 if err != nil {
73 t.Fatalf("EncodeMsgPack() failed: %v", err)
74 }
75
76 // Decode
77 var decoded testStruct
78 err = DecodeMsgPack(encoded, &decoded)
79 if err != nil {
80 t.Fatalf("DecodeMsgPack() failed: %v", err)
81 }
82
83 // Verify
84 if decoded.Name != original.Name || decoded.Value != original.Value {
85 t.Errorf("Decoded struct doesn't match original. Got %+v, want %+v", decoded, original)
86 }
87}
88
89// TestBufferPooling verifies that buffer pooling works correctly
90func TestBufferPooling(t *testing.T) {

Callers

nothing calls this directly

Calls 4

EncodeMsgPackFunction · 0.85
DecodeMsgPackFunction · 0.85
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected