Skip to content

Commit

Permalink
Add a test for Blob
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeiwan committed Dec 20, 2018
1 parent 0296aa5 commit b066e43
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,3 +517,24 @@ func EqualNoDiff(t *testing.T, expected interface{}, actual interface{}, message

return true
}

func TestBlob(t *testing.T) {
b := Blob("RU9TIEdv")

t.Run("String", func(tt *testing.T) {
assert.Equal(tt, "RU9TIEdv", b.String())
})

t.Run("Data", func(tt *testing.T) {
data, err := b.Data()
require.Nil(tt, err)
assert.Equal(tt, []byte("EOS Go"), data)
})

t.Run("malformed data", func(tt *testing.T) {
b := Blob("not base64")
data, err := b.Data()
require.Equal(tt, "illegal base64 data at input byte 3", err.Error())
assert.Empty(tt, data)
})
}

0 comments on commit b066e43

Please sign in to comment.