2020-11-19 05:08:49 +00:00
|
|
|
package registry
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2022-06-14 19:59:53 +00:00
|
|
|
|
|
|
|
"github.com/matryer/is"
|
2020-11-19 05:08:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestSource(t *testing.T) {
|
2022-06-14 19:59:53 +00:00
|
|
|
assert := is.New(t)
|
|
|
|
|
2020-11-19 05:08:49 +00:00
|
|
|
tt := []struct {
|
|
|
|
Name string
|
|
|
|
Source *Source
|
|
|
|
CloneURL string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
Name: "Gitea",
|
|
|
|
Source: &Source{
|
|
|
|
URL: "https://gitea.com/",
|
|
|
|
},
|
|
|
|
CloneURL: "https://gitea.com/user/repo.git",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "GitHub",
|
|
|
|
Source: &Source{
|
|
|
|
URL: "https://github.com/",
|
|
|
|
},
|
|
|
|
CloneURL: "https://github.com/user/repo.git",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Name: "GitLab",
|
|
|
|
Source: &Source{
|
|
|
|
URL: "https://gitlab.com/",
|
|
|
|
},
|
|
|
|
CloneURL: "https://gitlab.com/user/repo.git",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace := "user/repo"
|
|
|
|
for _, tc := range tt {
|
|
|
|
t.Run(tc.Name, func(t *testing.T) {
|
|
|
|
cloneURL := tc.Source.CloneURL(namespace)
|
2022-06-14 19:59:53 +00:00
|
|
|
assert.Equal(tc.CloneURL, cloneURL) // Clone URLs should match
|
2020-11-19 05:08:49 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|