github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/builder/remotecontext/urlutil/urlutil_test.go (about) 1 package urlutil // import "github.com/Prakhar-Agarwal-byte/moby/builder/remotecontext/urlutil" 2 3 import "testing" 4 5 var ( 6 gitUrls = []string{ 7 "git://github.com/Prakhar-Agarwal-byte/moby", 8 "git@github.com:docker/docker.git", 9 "git@bitbucket.org:atlassianlabs/atlassian-docker.git", 10 "https://github.com/Prakhar-Agarwal-byte/moby.git", 11 "http://github.com/Prakhar-Agarwal-byte/moby.git", 12 "http://github.com/Prakhar-Agarwal-byte/moby.git#branch", 13 "http://github.com/Prakhar-Agarwal-byte/moby.git#:dir", 14 } 15 incompleteGitUrls = []string{ 16 "github.com/Prakhar-Agarwal-byte/moby", 17 } 18 invalidGitUrls = []string{ 19 "http://github.com/Prakhar-Agarwal-byte/moby.git:#branch", 20 } 21 ) 22 23 func TestIsGIT(t *testing.T) { 24 for _, url := range gitUrls { 25 if !IsGitURL(url) { 26 t.Fatalf("%q should be detected as valid Git url", url) 27 } 28 } 29 30 for _, url := range incompleteGitUrls { 31 if !IsGitURL(url) { 32 t.Fatalf("%q should be detected as valid Git url", url) 33 } 34 } 35 36 for _, url := range invalidGitUrls { 37 if IsGitURL(url) { 38 t.Fatalf("%q should not be detected as valid Git prefix", url) 39 } 40 } 41 }