INNER CODE UNIT · Go
TestNewJsonMarshalBlob
cshum/imagor · blob_test.go:444
func TestNewJsonMarshalBlob(t *testing.T) {
b := NewBlobFromJsonMarshal(map[string]string{
"foo": "bar",
})
assert.Equal(t, BlobTypeJSON, b.BlobType())
assert.Equal(t, "application/json", b.ContentType())
assert.Equal(t, `{"foo":"bar"}`, string(b.Sniff()))
buf, _ := b.ReadAll()
assert.Equal(t, `{"foo":"bar"}`, string(buf))
}
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())
}