MCPcopy Create free account
hub / github.com/WICG/webpackage / TestWriteAndRead

Function TestWriteAndRead

go/bundle/bundle_test.go:109–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestWriteAndRead(t *testing.T) {
110 for _, ver := range version.AllVersions {
111 bundle := createTestBundle(t, ver)
112
113 var buf bytes.Buffer
114 n, err := bundle.WriteTo(&buf)
115 if err != nil {
116 t.Errorf("Bundle.WriteTo unexpectedly failed: %v", err)
117 }
118 if n != int64(buf.Len()) {
119 t.Errorf("Bundle.WriteTo returned %d, but wrote %d bytes", n, buf.Len())
120 }
121
122 deserialized, err := Read(&buf)
123 if err != nil {
124 t.Errorf("Bundle.Read unexpectedly failed: %v", err)
125 }
126 if !reflect.DeepEqual(deserialized, bundle) {
127 t.Errorf("got: %v\nwant: %v", deserialized, bundle)
128 }
129 }
130}
131
132func TestWriteAndReadWithVariants(t *testing.T) {
133 for _, ver := range version.AllVersions {

Callers

nothing calls this directly

Calls 4

createTestBundleFunction · 0.85
ReadFunction · 0.85
LenMethod · 0.65
WriteToMethod · 0.45

Tested by

no test coverage detected