github.com/pmorton/docker@v1.5.0/pkg/urlutil/git_test.go (about)

     1  package urlutil
     2  
     3  import "testing"
     4  
     5  var (
     6  	gitUrls = []string{
     7  		"git://github.com/docker/docker",
     8  		"git@github.com:docker/docker.git",
     9  		"git@bitbucket.org:atlassianlabs/atlassian-docker.git",
    10  		"https://github.com/docker/docker.git",
    11  		"http://github.com/docker/docker.git",
    12  	}
    13  	incompleteGitUrls = []string{
    14  		"github.com/docker/docker",
    15  	}
    16  )
    17  
    18  func TestValidGitTransport(t *testing.T) {
    19  	for _, url := range gitUrls {
    20  		if IsGitTransport(url) == false {
    21  			t.Fatalf("%q should be detected as valid Git prefix", url)
    22  		}
    23  	}
    24  
    25  	for _, url := range incompleteGitUrls {
    26  		if IsGitTransport(url) == true {
    27  			t.Fatalf("%q should not be detected as valid Git prefix", url)
    28  		}
    29  	}
    30  }
    31  
    32  func TestIsGIT(t *testing.T) {
    33  	for _, url := range gitUrls {
    34  		if IsGitURL(url) == false {
    35  			t.Fatalf("%q should be detected as valid Git url", url)
    36  		}
    37  	}
    38  	for _, url := range incompleteGitUrls {
    39  		if IsGitURL(url) == false {
    40  			t.Fatalf("%q should be detected as valid Git url", url)
    41  		}
    42  	}
    43  }