test(cmd/change): add ParseGithubURL test (#2339)
* test(cmd/change): add ParseGithubURL test * use anonymous structpull/2367/head
parent
cb69bf3714
commit
8d76eebf8b
@ -0,0 +1,25 @@ |
||||
package change |
||||
|
||||
import "testing" |
||||
|
||||
func TestParseGithubURL(t *testing.T) { |
||||
urls := []struct { |
||||
url string |
||||
owner string |
||||
repo string |
||||
}{ |
||||
{"https://github.com/go-kratos/kratos.git", "go-kratos", "kratos"}, |
||||
{"https://github.com/go-kratos/kratos", "go-kratos", "kratos"}, |
||||
{"git@github.com:go-kratos/kratos.git", "go-kratos", "kratos"}, |
||||
{"https://github.com/go-kratos/go-kratos.dev.git", "go-kratos", "go-kratos.dev"}, |
||||
} |
||||
for _, url := range urls { |
||||
owner, repo := ParseGithubURL(url.url) |
||||
if owner != url.owner { |
||||
t.Fatalf("owner want: %s, got: %s", owner, url.owner) |
||||
} |
||||
if repo != url.repo { |
||||
t.Fatalf("repo want: %s, got: %s", repo, url.repo) |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue