INNER CODE UNIT · Go

TestBlobJsonBytes

cshum/imagor · blob_test.go:462

func TestBlobJsonBytes(t *testing.T) {
	b := NewBlobFromBytes([]byte(`{"foo": "bar"}`))
	assert.Equal(t, BlobTypeJSON, b.BlobType())
	assert.Equal(t, "application/json", b.ContentType())
	assert.Equal(t, ".json", getExtension(b.BlobType()))
}

type readerFunc func(p []byte) (n int, err error)

func (rf readerFunc) Read(p []byte) (n int, err error) { return rf(p) }

func TestBlobCreateError(t *testing.T) {
	e := errors.New("some error")
	b := NewBlob(func() (reader io.ReadCloser, size int64, err error) {
		return nil, 0, e
	})
	assert.Equal(t, e, b.Err())
	buf, err := b.ReadAll()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…