From f199ca0c86a2aca80883bb461999222ddf5e7784 Mon Sep 17 00:00:00 2001 From: Reinaldy Rafli Date: Fri, 19 Nov 2021 18:00:40 +0700 Subject: [PATCH] test: panic on new --- cheapcash_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cheapcash_test.go b/cheapcash_test.go index e257fec..7c5760b 100644 --- a/cheapcash_test.go +++ b/cheapcash_test.go @@ -1,6 +1,7 @@ package cheapcash_test import ( + "errors" "log" "os" "testing" @@ -29,6 +30,19 @@ func TestNew(t *testing.T) { } } +func TestNew_InvalidPath(t *testing.T) { + defer func(){ + if e := recover().(error); e != nil { + if !errors.Is(e, cheapcash.ErrInvalidPath) { + t.Error("expected ErrInvalidPath, got:", e) + } + } + }() + + _ = cheapcash.New("") + +} + func removeDirIfExists(path string) { dir, err := os.Stat(path) if err == nil {