summaryrefslogtreecommitdiff
path: root/funcs/file_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'funcs/file_test.go')
-rw-r--r--funcs/file_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/funcs/file_test.go b/funcs/file_test.go
new file mode 100644
index 00000000..2a3ce9a9
--- /dev/null
+++ b/funcs/file_test.go
@@ -0,0 +1,32 @@
+package funcs
+
+import (
+ "testing"
+
+ "github.com/spf13/afero"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestFileExists(t *testing.T) {
+ fs := afero.NewMemMapFs()
+ ff := &FileFuncs{fs}
+
+ _ = fs.Mkdir("/tmp", 0777)
+ f, _ := fs.Create("/tmp/foo")
+ _, _ = f.Write([]byte("foo"))
+
+ assert.True(t, ff.Exists("/tmp/foo"))
+ assert.False(t, ff.Exists("/tmp/bar"))
+}
+
+func TestFileIsDir(t *testing.T) {
+ fs := afero.NewMemMapFs()
+ ff := &FileFuncs{fs}
+
+ _ = fs.Mkdir("/tmp", 0777)
+ f, _ := fs.Create("/tmp/foo")
+ _, _ = f.Write([]byte("foo"))
+
+ assert.True(t, ff.IsDir("/tmp"))
+ assert.False(t, ff.IsDir("/tmp/foo"))
+}