diff --git a/utils/utils_unix_test.go b/utils/utils_darwin_test.go similarity index 93% rename from utils/utils_unix_test.go rename to utils/utils_darwin_test.go index 662a2ae6..3bca965b 100644 --- a/utils/utils_unix_test.go +++ b/utils/utils_darwin_test.go @@ -1,9 +1,8 @@ -//go:build unix -// +build unix - package utils -import "testing" +import ( + "testing" +) func TestSourceDir(t *testing.T) { cases := []struct { diff --git a/utils/utils_linux_test.go b/utils/utils_linux_test.go new file mode 100644 index 00000000..3bca965b --- /dev/null +++ b/utils/utils_linux_test.go @@ -0,0 +1,35 @@ +package utils + +import ( + "testing" +) + +func TestSourceDir(t *testing.T) { + cases := []struct { + file string + want string + }{ + { + file: "/Users/name/go/pkg/mod/gorm.io/gorm@v1.2.3/utils/utils.go", + want: "/Users/name/go/pkg/mod/gorm.io/", + }, + { + file: "/go/work/proj/gorm/utils/utils.go", + want: "/go/work/proj/gorm/", + }, + { + file: "/go/work/proj/gorm_alias/utils/utils.go", + want: "/go/work/proj/gorm_alias/", + }, + { + file: "/go/work/proj/my.gorm.io/gorm@v1.2.3/utils/utils.go", + want: "/go/work/proj/my.gorm.io/gorm@v1.2.3/", + }, + } + for _, c := range cases { + s := sourceDir(c.file) + if s != c.want { + t.Fatalf("%s: expected %s, got %s", c.file, c.want, s) + } + } +} diff --git a/utils/utils_windows_test.go b/utils/utils_windows_test.go index bc36615e..8b1c519d 100644 --- a/utils/utils_windows_test.go +++ b/utils/utils_windows_test.go @@ -1,9 +1,8 @@ -//go:build windows -// +build windows - package utils -import "testing" +import ( + "testing" +) func TestSourceDir(t *testing.T) { cases := []struct {