archiver/Globbing_linux_test.go

28 lines
831 B
Go
Raw Normal View History

2024-09-26 11:33:03 +02:00
package archiver
import "testing"
func TestGetGlobRoot(t *testing.T) {
assertThat(t, getGlobRoot("/foo/bar/baz"), "/foo/bar/baz")
assertThat(t, getGlobRoot("/foo/bar/*/baz"), "/foo/bar")
assertThat(t, getGlobRoot("/foo/bar/*"), "/foo/bar")
assertThat(t, getGlobRoot("foo/bar/*"), "foo/bar")
assertThat(t, getGlobRoot("./foo/bar/*"), "./foo/bar")
}
func TestGetGlobbedDir(t *testing.T) {
assertThat(t, extractGlobbedDir("/foo/bar/baz", "/foo/bar/baz/myFile.txt"), "")
assertThat(t, extractGlobbedDir("/foo/bar/*", "/foo/bar/myDir/myFile.txt"), "myDir")
assertThat(t, extractGlobbedDir("/foo/bar/*/baz", "/foo/bar/myDir/baz/myFile.txt"), "myDir/baz")
}
2024-09-26 11:53:37 +02:00
2024-09-26 11:33:03 +02:00
func assertThat[E comparable](t *testing.T, actual E, expected E) {
t.Helper()
if actual != expected {
t.Errorf("actual %v, expected %v", actual, expected)
}
}