add verification on nil log

Signed-off-by: Benjamin Wang <wachao@vmware.com>
This commit is contained in:
Benjamin Wang
2022-09-13 17:11:36 +08:00
parent b886bbc89f
commit 47d460b8dc
4 changed files with 22 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"go.uber.org/zap/zaptest"
)
@ -218,3 +219,14 @@ func TestRemoveMatchFile(t *testing.T) {
t.Errorf("expected error, got nil")
}
}
func TestTouchDirAll(t *testing.T) {
tmpdir := t.TempDir()
assert.Panics(t, func() {
TouchDirAll(nil, tmpdir)
}, "expected panic with nil log")
if err := TouchDirAll(zaptest.NewLogger(t), tmpdir); err != nil {
t.Fatal(err)
}
}