MCPcopy Create free account
hub / github.com/blobcache/blobcache / TestMessageReadWrite

Function TestMessageReadWrite

src/bcp/bcp_test.go:20–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

18}
19
20func TestMessageReadWrite(t *testing.T) {
21 m := Message{}
22 m.SetCode(MT_OPEN_FROM)
23 m.SetBody([]byte("hello"))
24
25 buf := &bytes.Buffer{}
26 _, err := m.WriteTo(buf)
27 require.NoError(t, err)
28
29 m2 := Message{}
30 _, err = m2.ReadFrom(buf)
31 require.NoError(t, err)
32
33 require.Equal(t, m2.Header().Code(), MT_OPEN_FROM)
34 require.Equal(t, m2.Header().BodyLen(), len("hello"))
35 require.Equal(t, string(m2.Body()), "hello")
36}
37
38func TestPermissionWireError(t *testing.T) {
39 m := Message{}

Callers

nothing calls this directly

Calls 8

SetCodeMethod · 0.95
SetBodyMethod · 0.95
WriteToMethod · 0.95
ReadFromMethod · 0.95
HeaderMethod · 0.95
BodyMethod · 0.95
CodeMethod · 0.80
BodyLenMethod · 0.80

Tested by

no test coverage detected