test: panic on new

This commit is contained in:
Reinaldy Rafli 2021-11-19 18:00:40 +07:00
parent a533c96551
commit f199ca0c86
No known key found for this signature in database
GPG Key ID: CFDB9400255D8CB6
1 changed files with 14 additions and 0 deletions

View File

@ -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 {