Christian Schmied
1fa1d47e63
All checks were successful
go/archiver/pipeline/head This commit looks good
27 lines
831 B
Go
27 lines
831 B
Go
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")
|
|
}
|
|
|
|
func assertThat[E comparable](t *testing.T, actual E, expected E) {
|
|
t.Helper()
|
|
if actual != expected {
|
|
t.Errorf("actual %v, expected %v", actual, expected)
|
|
}
|
|
}
|