Home

tmpl @4987bf8aed021ee787d751eea7934b8f1ab8693a - refs - log -
-
https://git.jolheiser.com/tmpl.git
Template automation
tmpl / registry / source_test.go
- raw
 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
35
36
37
38
39
40
41
42
43
44
45
46
47
package registry

import (
	"strings"
	"testing"
)

func TestSource(t *testing.T) {
	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)
			if !strings.EqualFold(tc.CloneURL, cloneURL) {
				t.Logf("incorrect clone URL:\n\tExpected: %s\n\tGot: %s\n", tc.CloneURL, cloneURL)
				t.Fail()
			}
		})
	}
}