diff --git a/commands/clone_test.go b/commands/clone_test.go index 137a1357..52bb7c2d 100644 --- a/commands/clone_test.go +++ b/commands/clone_test.go @@ -9,8 +9,7 @@ import ( func TestTransformCloneArgs(t *testing.T) { os.Setenv("GH_PROTOCOL", "git") - - github.CreateTestConfig("jingweno", "123") + github.CreateTestConfigs("jingweno", "123") args := NewArgs([]string{"clone", "foo/gh"}) transformCloneArgs(args) @@ -28,7 +27,7 @@ func TestTransformCloneArgs(t *testing.T) { transformCloneArgs(args) assert.Equal(t, 1, args.ParamsSize()) - assert.Equal(t, "git@github.com:jingweno/gh.git", args.FirstParam()) + assert.Equal(t, "git://github.com/jingweno/gh.git", args.FirstParam()) args = NewArgs([]string{"clone", "-p", "acl-services/devise-acl"}) transformCloneArgs(args) diff --git a/github/configs.go b/github/configs.go index 15d6e1d1..f640b77c 100644 --- a/github/configs.go +++ b/github/configs.go @@ -6,6 +6,7 @@ import ( "github.com/howeyc/gopass" "github.com/jingweno/gh/utils" "io" + "io/ioutil" "os" "path/filepath" "regexp" @@ -133,3 +134,15 @@ func CurrentConfigs() *Configs { return &Configs{c} } + +func CreateTestConfigs(user, token string) []Credentials { + f, _ := ioutil.TempFile("", "test-config") + defaultConfigsFile = f.Name() + + c := []Credentials{ + {User: "jingweno", AccessToken: "123", Host: GitHubHost}, + } + saveTo(f.Name(), &c) + + return c +}