123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- package urlutil // import "github.com/docker/docker/builder/remotecontext/urlutil"
- import "testing"
- var (
- gitUrls = []string{
- "git://github.com/docker/docker",
- "git@github.com:docker/docker.git",
- "git@bitbucket.org:atlassianlabs/atlassian-docker.git",
- "https://github.com/docker/docker.git",
- "http://github.com/docker/docker.git",
- "http://github.com/docker/docker.git#branch",
- "http://github.com/docker/docker.git#:dir",
- "ssh://git@github.com/docker/docker.git",
- "ssh://a_user@github.com/docker/docker.git",
- "ssh://github.com/docker/docker.git",
- }
- incompleteGitUrls = []string{
- "github.com/docker/docker",
- }
- invalidGitUrls = []string{
- "http://github.com/docker/docker.git:#branch",
- "https://github.com/docker/dgit",
- }
- )
- func TestIsGIT(t *testing.T) {
- for _, url := range gitUrls {
- if !IsGitURL(url) {
- t.Fatalf("%q should be detected as valid Git url", url)
- }
- }
- for _, url := range incompleteGitUrls {
- if !IsGitURL(url) {
- t.Fatalf("%q should be detected as valid Git url", url)
- }
- }
- for _, url := range invalidGitUrls {
- if IsGitURL(url) {
- t.Fatalf("%q should not be detected as valid Git prefix", url)
- }
- }
- }
|