MCPcopy
hub / github.com/bitfield/script / TestDirname_RemovesFilenameComponentFromInputLines

Function TestDirname_RemovesFilenameComponentFromInputLines

script_test.go:211–242  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

209}
210
211func TestDirname_RemovesFilenameComponentFromInputLines(t *testing.T) {
212 t.Parallel()
213 tcs := []struct {
214 path string
215 want string
216 }{
217 {"/", "/\n"},
218 {"./", ".\n"},
219 {"\n", ".\n"},
220 {"/root", "/\n"},
221 {"/tmp/example.php", "/tmp\n"},
222 {"/var/tmp/example.php", "/var/tmp\n"},
223 {"/var/tmp", "/var\n"},
224 {"/var/tmp/", "/var\n"},
225 {"src/filters", "./src\n"},
226 {"src/filters/", "./src\n"},
227 {"/tmp/script-21345.txt\n/tmp/script-5371253.txt", "/tmp\n/tmp\n"},
228 {"C:/Program Files/PHP", "C:/Program Files\n"},
229 {"C:/Program Files/PHP/", "C:/Program Files\n"},
230 }
231 for _, tc := range tcs {
232 // Expect results to use this platform's path separator
233 want := filepath.Clean(tc.want)
234 got, err := script.Echo(tc.path).Dirname().String()
235 if err != nil {
236 t.Fatal(err)
237 }
238 if want != got {
239 t.Errorf("%q: want %q, got %q", tc.path, want, got)
240 }
241 }
242}
243
244func TestDoPerformsSuppliedHTTPRequest(t *testing.T) {
245 t.Parallel()

Callers

nothing calls this directly

Calls 3

EchoFunction · 0.92
StringMethod · 0.80
DirnameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…