Exemple #1
0
func Test_parseValidBlob(t *testing.T) {
	for _, v := range testCasesBlobs {
		tb := makeTestBlob(v)
		p := ObjectParserForString(tb)
		hdr, err := p.ParseHeader()
		util.AssertNoErr(t, err)
		util.Assert(t, hdr.Type() == objects.ObjectBlob)
		util.Assert(t, hdr.Size() == int64(len(v)))

		o, err := p.ParsePayload()
		util.AssertNoErr(t, err)
		util.Assert(t, o.Header().Type() == objects.ObjectBlob)
		util.Assert(t, o.Header().Size() == int64(len(v)))
		util.Assert(t, o.ObjectId() == nil) // wasn't set in the test scenario

		var b *objects.Blob
		util.AssertPanicFree(t, func() {
			b = o.(*objects.Blob)
		})
		util.AssertEqualString(t, string(b.Data()), v)
	}
}
Exemple #2
0
// Blob formats the contents of the blog as a string
// for output to the screen.
func (f *formatter) Blob(b *objects.Blob) (int, error) {
	return fmt.Fprintf(f.Writer, "%s", string(b.Data()))
}