From b066e438399f12b66debb8135bb567d26c8bee9c Mon Sep 17 00:00:00 2001 From: Ivan Kuznetsov Date: Thu, 20 Dec 2018 15:03:45 +0700 Subject: [PATCH] Add a test for Blob --- types_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/types_test.go b/types_test.go index b2a61194..b1b8c331 100644 --- a/types_test.go +++ b/types_test.go @@ -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) + }) +}