github.com/instill-ai/component@v0.16.0-beta/pkg/connector/util/helper_test.go (about) 1 package util 2 3 import ( 4 "testing" 5 6 qt "github.com/frankban/quicktest" 7 ) 8 9 func TestDecodeBase46(t *testing.T) { 10 c := qt.New(t) 11 12 c.Run("ok - with MIME prepended", func(c *qt.C) { 13 in := "data:text/plain;base64,aG9sYQ==" 14 got, err := DecodeBase64(in) 15 c.Check(err, qt.IsNil) 16 c.Check(got, qt.ContentEquals, []byte("hola")) 17 }) 18 19 c.Run("ok - with MIME prepended", func(c *qt.C) { 20 in := "aG9sYQ==" 21 got, err := DecodeBase64(in) 22 c.Check(err, qt.IsNil) 23 c.Check(got, qt.ContentEquals, []byte("hola")) 24 }) 25 26 c.Run("nok - invalid", func(c *qt.C) { 27 in := "hola==" 28 _, err := DecodeBase64(in) 29 c.Check(err, qt.IsNotNil) 30 }) 31 }