diff options
Diffstat (limited to 'repository/gogit_test.go')
-rw-r--r-- | repository/gogit_test.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/repository/gogit_test.go b/repository/gogit_test.go index 21acd5df..dff94605 100644 --- a/repository/gogit_test.go +++ b/repository/gogit_test.go @@ -2,6 +2,7 @@ package repository import ( "fmt" + "log" "os" "path" "path/filepath" @@ -96,3 +97,48 @@ func TestGoGit_DetectsSubmodules(t *testing.T) { assert.Empty(t, err) assert.Equal(t, expected, result) } + +func TestGoGitRepoSSH(t *testing.T) { + repo := CreateGoGitTestRepo(t, false) + + err := repo.AddRemote("ssh", "ssh://git@github.com:MichaelMure/git-bug.git") + if err != nil { + log.Fatal(err) + } + keys, err := repo.SSHAuth("ssh") + require.NotNil(t, keys) + require.Empty(t, err) + + err = repo.AddRemote("http", "http://github.com/MichaelMure/git-bug.git") + if err != nil { + log.Fatal(err) + } + keys, err = repo.SSHAuth("http") + require.Nil(t, keys) + require.Empty(t, err) + + err = repo.AddRemote("https", "https://github.com/MichaelMure/git-bug.git") + if err != nil { + log.Fatal(err) + } + keys, err = repo.SSHAuth("https") + require.Nil(t, keys) + require.Empty(t, err) + + err = repo.AddRemote("git", "git://github.com/MichaelMure/git-bug.git") + if err != nil { + log.Fatal(err) + } + keys, err = repo.SSHAuth("git") + require.Nil(t, keys) + require.Empty(t, err) + + err = repo.AddRemote("scp-like", "git@github.com:MichaelMure/git-bug.git") + if err != nil { + log.Fatal(err) + } + keys, err = repo.SSHAuth("scp-like") + require.NotNil(t, keys) + require.Empty(t, err) + +} |