-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
39 lines (31 loc) · 1.24 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import "testing"
import (
"github.com/stretchr/testify/assert"
"go/build"
"path/filepath"
)
func TestParseRawURL(t *testing.T) {
// SSH remote style
dir, remote := parseRawURL("[email protected]:brentnd/git-get.git")
assert.Equal(t, filepath.FromSlash(build.Default.GOPATH+"/src/github.com/brentnd/git-get"), dir)
assert.Equal(t, "[email protected]:brentnd/git-get.git", remote)
// HTTPS remote style
dir, remote = parseRawURL("https://github.com/brentnd/git-get.git")
assert.Equal(t, filepath.FromSlash(build.Default.GOPATH+"/src/github.com/brentnd/git-get"), dir)
assert.Equal(t, "https://github.com/brentnd/git-get.git", remote)
// Golang package style
dir, remote = parseRawURL("github.com/brentnd/git-get")
assert.Equal(t, filepath.FromSlash(build.Default.GOPATH+"/src/github.com/brentnd/git-get"), dir)
assert.Equal(t, "https://github.com/brentnd/git-get.git", remote)
}
func TestRemoteRepoExists(t *testing.T) {
err := remoteRepoExists("https://github.com/brentnd/git-get.git")
assert.Nil(t, err)
err = remoteRepoExists("[email protected]:brentnd/git-get.git")
assert.Nil(t, err)
err = remoteRepoExists("[email protected]:brentnd/missing.git")
assert.NotNil(t, err)
err = remoteRepoExists("bad-input-for-repo")
assert.NotNil(t, err)
}