From 3b9a65a7ad72f14c639e1296ae04c51b720ccac5 Mon Sep 17 00:00:00 2001 From: u5surf Date: Fri, 20 Sep 2019 08:21:09 +0900 Subject: [PATCH] inclease more test coverage with covering Encrypt/Decrypt without SetCryptKey #6 --- cryptkeeper_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cryptkeeper_test.go b/cryptkeeper_test.go index fb20df4..b63acd6 100644 --- a/cryptkeeper_test.go +++ b/cryptkeeper_test.go @@ -27,6 +27,20 @@ func TestCryptSetup(t *testing.T) { func TestCryptString(t *testing.T) { + t.Run("Invalid without SetCryptKey", func(t *testing.T) { + t.Run("Invalid Encrypt", func(t *testing.T) { + _, err := Encrypt("abc") + if err == nil { + t.Fatalf("Encrypt without SetCryptKey should have errored: '%s'", err) + } + }) + t.Run("Invalid Decrypt", func(t *testing.T) { + _, err := Decrypt("2tHq4GL8r7tTvfk6l2TS8d5nVDXY6ztqz6WTmbmq8ZOJ") + if err == nil { + t.Fatalf("Decrypt without SetCryptKey should have errored: %s", err) + } + }) + }) t.Run("Encrypt/Valid", func(t *testing.T) { err := SetCryptKey([]byte("12345678901234567890123456789012")) if err != nil {