urlutil_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package urlutil // import "github.com/docker/docker/builder/remotecontext/urlutil"
  2. import "testing"
  3. var (
  4. gitUrls = []string{
  5. "git://github.com/docker/docker",
  6. "git@github.com:docker/docker.git",
  7. "git@bitbucket.org:atlassianlabs/atlassian-docker.git",
  8. "https://github.com/docker/docker.git",
  9. "http://github.com/docker/docker.git",
  10. "http://github.com/docker/docker.git#branch",
  11. "http://github.com/docker/docker.git#:dir",
  12. "ssh://git@github.com/docker/docker.git",
  13. "ssh://a_user@github.com/docker/docker.git",
  14. "ssh://github.com/docker/docker.git",
  15. }
  16. incompleteGitUrls = []string{
  17. "github.com/docker/docker",
  18. }
  19. invalidGitUrls = []string{
  20. "http://github.com/docker/docker.git:#branch",
  21. "https://github.com/docker/dgit",
  22. }
  23. )
  24. func TestIsGIT(t *testing.T) {
  25. for _, url := range gitUrls {
  26. if !IsGitURL(url) {
  27. t.Fatalf("%q should be detected as valid Git url", url)
  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. for _, url := range invalidGitUrls {
  36. if IsGitURL(url) {
  37. t.Fatalf("%q should not be detected as valid Git prefix", url)
  38. }
  39. }
  40. }