github.com/phsym/gomarkdoc@v0.5.4/lang/config_test.go (about) 1 package lang 2 3 import ( 4 "testing" 5 6 "github.com/matryer/is" 7 ) 8 9 func TestNormalizeRemote(t *testing.T) { 10 tests := map[string]struct { 11 raw string 12 normalized string 13 }{ 14 "GitHub https": { 15 raw: "https://github.com/org/repo.git", 16 normalized: "https://github.com/org/repo", 17 }, 18 "GitHub ssh": { 19 raw: "git@github.com:org/repo.git", 20 normalized: "https://github.com/org/repo", 21 }, 22 "Azure DevOps https": { 23 raw: "https://org@dev.azure.com/org/project/_git/repo", 24 normalized: "https://dev.azure.com/org/project/_git/repo", 25 }, 26 "Azure DevOps ssh": { 27 raw: "git@ssh.dev.azure.com:v3/org/project/repo", 28 normalized: "https://dev.azure.com/org/project/_git/repo", 29 }, 30 "Azure DevOps https (visualstudio.com)": { 31 raw: "https://org.visualstudio.com/DefaultCollection/project/_git/repo", 32 normalized: "https://dev.azure.com/org/project/_git/repo", 33 }, 34 "Azure DevOps ssh (visualstudio.com)": { 35 raw: "org@vs-ssh.visualstudio.com:v3/org/project/repo", 36 normalized: "https://dev.azure.com/org/project/_git/repo", 37 }, 38 "GitLab https": { 39 raw: "https://gitlab.com/org/repo.git", 40 normalized: "https://gitlab.com/org/repo", 41 }, 42 "GitLab ssh": { 43 raw: "git@gitlab.com:org/repo.git", 44 normalized: "https://gitlab.com/org/repo", 45 }, 46 } 47 48 for name, test := range tests { 49 t.Run(name, func(t *testing.T) { 50 is := is.New(t) 51 52 normalized, ok := normalizeRemote(test.raw) 53 is.True(ok) // Didn't produce a normlized value 54 is.Equal(normalized, test.normalized) // Wrong normalized value 55 }) 56 } 57 }