|
15 | 15 | package environment |
16 | 16 |
|
17 | 17 | import ( |
18 | | - "os" |
19 | 18 | "path/filepath" |
20 | 19 | "strings" |
21 | 20 | "testing" |
22 | 21 |
|
23 | 22 | "k8s.io/client-go/util/homedir" |
24 | 23 |
|
25 | | - "sigs.k8s.io/krew/internal/testutil" |
26 | 24 | "sigs.k8s.io/krew/pkg/constants" |
27 | 25 | ) |
28 | 26 |
|
@@ -78,48 +76,3 @@ func TestPaths(t *testing.T) { |
78 | 76 | t.Errorf("PluginInstallReceiptPath()=%s; expected suffix 'receipts/my-plugin.yaml'", got) |
79 | 77 | } |
80 | 78 | } |
81 | | - |
82 | | -func TestRealpath(t *testing.T) { |
83 | | - tmpDir := testutil.NewTempDir(t) |
84 | | - |
85 | | - // create regular file |
86 | | - tmpDir.Write("regular-file", nil) |
87 | | - |
88 | | - // create absolute symlink |
89 | | - orig := filepath.Clean(os.TempDir()) |
90 | | - if err := os.Symlink(orig, filepath.Join(tmpDir.Root(), "symbolic-link-abs")); err != nil { |
91 | | - t.Fatal(err) |
92 | | - } |
93 | | - |
94 | | - // create relative symlink |
95 | | - if err := os.Symlink("./another-file", filepath.Join(tmpDir.Root(), "symbolic-link-rel")); err != nil { |
96 | | - t.Fatal(err) |
97 | | - } |
98 | | - |
99 | | - tests := []struct { |
100 | | - name string |
101 | | - in string |
102 | | - want string |
103 | | - wantErr bool |
104 | | - }{ |
105 | | - {"file not exists", tmpDir.Path("/not/exists"), "", true}, |
106 | | - {"directory", tmpDir.Root(), tmpDir.Root(), false}, |
107 | | - {"regular file", tmpDir.Path("regular-file"), tmpDir.Path("regular-file"), false}, |
108 | | - {"directory unclean", tmpDir.Path("foo/.."), tmpDir.Root(), false}, |
109 | | - {"regular file unclean", tmpDir.Path("regular-file/foo/.."), tmpDir.Path("regular-file"), false}, |
110 | | - {"relative symbolic link", tmpDir.Path("symbolic-link-rel"), "", true}, |
111 | | - {"absolute symbolic link", tmpDir.Path("symbolic-link-abs"), orig, false}, |
112 | | - } |
113 | | - for _, tt := range tests { |
114 | | - t.Run(tt.name, func(t *testing.T) { |
115 | | - got, err := Realpath(tt.in) |
116 | | - if (err != nil) != tt.wantErr { |
117 | | - t.Errorf("Realpath(%s) error = %v, wantErr %v", tt.in, err, tt.wantErr) |
118 | | - return |
119 | | - } |
120 | | - if got != tt.want { |
121 | | - t.Errorf("Realpath(%s) = %v, want %v", tt.in, got, tt.want) |
122 | | - } |
123 | | - }) |
124 | | - } |
125 | | -} |
0 commit comments