aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/cli/internal/fs/fs_test.go
diff options
context:
space:
mode:
author简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:55 +0800
committer简律纯 <hsiangnianian@outlook.com>2023-04-28 01:36:55 +0800
commitfc8c5fdce62fb229202659408798a7b6c98f6e8b (patch)
tree7554f80e50de4af6fd255afa7c21bcdd58a7af34 /cli/internal/fs/fs_test.go
parentdd84b9d64fb98746a230cd24233ff50a562c39c9 (diff)
downloadHydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.tar.gz
HydroRoll-fc8c5fdce62fb229202659408798a7b6c98f6e8b.zip
Diffstat (limited to 'cli/internal/fs/fs_test.go')
-rw-r--r--cli/internal/fs/fs_test.go60
1 files changed, 0 insertions, 60 deletions
diff --git a/cli/internal/fs/fs_test.go b/cli/internal/fs/fs_test.go
deleted file mode 100644
index 0598d43..0000000
--- a/cli/internal/fs/fs_test.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package fs
-
-import (
- "path/filepath"
- "testing"
-)
-
-func Test_DirContainsPath(t *testing.T) {
- parent, err := filepath.Abs(filepath.Join("some", "path"))
- if err != nil {
- t.Fatalf("failed to construct parent path %v", err)
- }
- testcases := []struct {
- target []string
- want bool
- }{
- {
- []string{"..", "elsewhere"},
- false,
- },
- {
- []string{"sibling"},
- false,
- },
- {
- // The same path as parent
- []string{"some", "path"},
- true,
- },
- {
- []string{"some", "path", "..", "path", "inside", "parent"},
- true,
- },
- {
- []string{"some", "path", "inside", "..", "inside", "parent"},
- true,
- },
- {
- []string{"some", "path", "inside", "..", "..", "outside", "parent"},
- false,
- },
- {
- []string{"some", "pathprefix"},
- false,
- },
- }
- for _, tc := range testcases {
- target, err := filepath.Abs(filepath.Join(tc.target...))
- if err != nil {
- t.Fatalf("failed to construct path for %v: %v", tc.target, err)
- }
- got, err := DirContainsPath(parent, target)
- if err != nil {
- t.Fatalf("failed to check ")
- }
- if got != tc.want {
- t.Errorf("DirContainsPath(%v, %v) got %v, want %v", parent, target, got, tc.want)
- }
- }
-}