git_test.go 976 B

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