INNER CODE UNIT · Go
TestBlobOverrideContentType
cshum/imagor · blob_test.go:455
func TestBlobOverrideContentType(t *testing.T) {
b := NewBlobFromFile("testdata/demo1.jpg")
b.SetContentType("foo/bar")
assert.Equal(t, BlobTypeJPEG, b.BlobType())
assert.Equal(t, "foo/bar", b.ContentType())
}
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) }