-
Notifications
You must be signed in to change notification settings - Fork 189
/
utils_test.go
34 lines (32 loc) · 1.26 KB
/
utils_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package admin
import (
"fmt"
"testing"
)
func TestGetDepVersionFromMod(t *testing.T) {
goModDeps = []string{
"github.com/qor/l10n v0.0.0-20181031091737-2ca95fb3b4dd // indirect",
"github.com/qor/admin v1.1.1",
"github.com/qor/publish2 v1.1.0 // indirect",
"github.com/qor/media v0.0.0-20191022071353-19cf289e17d4 // indirect",
"github.com/qor/i18n v2.0.7",
}
cases := []struct {
view string
want string
}{
{view: "github.com/qor/l10n/views", want: "pkg/mod/github.com/qor/l10n@v0.0.0-20181031091737-2ca95fb3b4dd/views"},
{view: "github.com/qor/admin/views", want: "pkg/mod/github.com/qor/admin@v1.1.1/views"},
{view: "github.com/qor/publish2/views", want: "pkg/mod/github.com/qor/publish2@v1.1.0/views"},
{view: "github.com/qor/media/media_library/views", want: "pkg/mod/github.com/qor/media@v0.0.0-20191022071353-19cf289e17d4/media_library/views"},
{view: "github.com/qor/i18n/exchange_actions/views", want: "pkg/mod/github.com/qor/i18n@v2.0.7/exchange_actions/views"},
{view: "no/unknown/nonexistent", want: "no/unknown/nonexistent"},
}
for _, v := range cases {
if got := getDepVersionFromMod("", v.view); v.want != got {
t.Errorf("GetDepVersionFromMod-viewpath: %v, want: %v, got: %v", v.view, v.want, got)
} else {
fmt.Println(got)
}
}
}