urlutil_test.go 1003 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. }
  13. incompleteGitUrls = []string{
  14. "github.com/docker/docker",
  15. }
  16. invalidGitUrls = []string{
  17. "http://github.com/docker/docker.git:#branch",
  18. }
  19. )
  20. func TestIsGIT(t *testing.T) {
  21. for _, url := range gitUrls {
  22. if !IsGitURL(url) {
  23. t.Fatalf("%q should be detected as valid Git url", url)
  24. }
  25. }
  26. for _, url := range incompleteGitUrls {
  27. if !IsGitURL(url) {
  28. t.Fatalf("%q should be detected as valid Git url", url)
  29. }
  30. }
  31. for _, url := range invalidGitUrls {
  32. if IsGitURL(url) {
  33. t.Fatalf("%q should not be detected as valid Git prefix", url)
  34. }
  35. }
  36. }