Skip to content

Commit ee30ef0

Browse files
committed
Unit tests added
1 parent d6f79f0 commit ee30ef0

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed

plugin_unix_test.go

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,42 @@ func TestResolveDir(t *testing.T) {
7979
}
8080
}
8181
}
82+
83+
func TestNormalizePath(t *testing.T) {
84+
tests := []struct {
85+
input string
86+
expected string
87+
}{
88+
{
89+
input: "/path/to/file.txt",
90+
expected: "path/to/file.txt",
91+
},
92+
{
93+
input: "C:\\Users\\username\\Documents\\file.doc",
94+
expected: "C:\\Users\\username\\Documents\\file.doc",
95+
},
96+
{
97+
input: "relative/path/to/file",
98+
expected: "relative/path/to/file",
99+
},
100+
{
101+
input: "file.txt",
102+
expected: "file.txt",
103+
},
104+
{
105+
input: "/root/directory/",
106+
expected: "root/directory/",
107+
},
108+
{
109+
input: "no_slash",
110+
expected: "no_slash",
111+
},
112+
}
113+
114+
for _, tc := range tests {
115+
result := normalizePath(tc.input)
116+
if result != tc.expected {
117+
t.Errorf("Expected: %s, Got: %s", tc.expected, result)
118+
}
119+
}
120+
}

plugin_windows_test.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,77 @@ func TestResolveWinKey(t *testing.T) {
5858
}
5959
}
6060
}
61+
62+
func TestResolveDir(t *testing.T) {
63+
tests := []struct {
64+
input string
65+
expected string
66+
}{
67+
{
68+
input: "example-string",
69+
expected: "example-string",
70+
},
71+
{
72+
input: "/path/to/file",
73+
expected: "path/to/file",
74+
},
75+
{
76+
input: "12345",
77+
expected: "12345",
78+
},
79+
{
80+
input: "/root/directory",
81+
expected: "root/directory",
82+
},
83+
{
84+
input: "no_slash",
85+
expected: "no_slash",
86+
},
87+
}
88+
89+
for _, tc := range tests {
90+
result := resolveDir(tc.input)
91+
if result != tc.expected {
92+
t.Errorf("Expected: %s, Got: %s", tc.expected, result)
93+
}
94+
}
95+
}
96+
97+
func TestNormalizePath(t *testing.T) {
98+
tests := []struct {
99+
input string
100+
expected string
101+
}{
102+
{
103+
input: "/path/to/file.txt",
104+
expected: "path/to/file.txt",
105+
},
106+
{
107+
input: "C:\\Users\\username\\Documents\\file.doc",
108+
expected: "C:\\Users\\username\\Documents\\file.doc",
109+
},
110+
{
111+
input: "relative/path/to/file",
112+
expected: "relative/path/to/file",
113+
},
114+
{
115+
input: "file.txt",
116+
expected: "file.txt",
117+
},
118+
{
119+
input: "/root/directory/",
120+
expected: "root/directory/",
121+
},
122+
{
123+
input: "no_slash",
124+
expected: "no_slash",
125+
},
126+
}
127+
128+
for _, tc := range tests {
129+
result := normalizePath(tc.input)
130+
if result != tc.expected {
131+
t.Errorf("Expected: %s, Got: %s", tc.expected, result)
132+
}
133+
}
134+
}

0 commit comments

Comments
 (0)