github.com/mloves0824/enron/cmd/enron@v0.0.0-20230830012320-113bbf6be3c8/internal/change/get_test.go (about) 1 package change 2 3 import "testing" 4 5 func TestParseGithubURL(t *testing.T) { 6 urls := []struct { 7 url string 8 owner string 9 repo string 10 }{ 11 {"https://github.com/go-kratos/kratos.git", "go-kratos", "kratos"}, 12 {"https://github.com/go-kratos/kratos", "go-kratos", "kratos"}, 13 {"git@github.com:go-kratos/kratos.git", "go-kratos", "kratos"}, 14 {"https://github.com/go-kratos/go-kratos.dev.git", "go-kratos", "go-kratos.dev"}, 15 } 16 for _, url := range urls { 17 owner, repo := ParseGithubURL(url.url) 18 if owner != url.owner { 19 t.Fatalf("owner want: %s, got: %s", owner, url.owner) 20 } 21 if repo != url.repo { 22 t.Fatalf("repo want: %s, got: %s", repo, url.repo) 23 } 24 } 25 }