Skip to content

Commit 6dcc4f2

Browse files
test: fix git clone tests for ssh (#47)
1 parent 1d45bef commit 6dcc4f2

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

internal/util/repository_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,25 @@ func Test_GetRepositoryUrl_repo_without_credentials(t *testing.T) {
7474
func Test_GetRepositoryUrl_repo_with_ssh(t *testing.T) {
7575
// check out a repo and prepare its config to contain credentials in the URL
7676
expectedRepoUrl := "https://github.com/snyk-fixtures/shallow-goof-locked.git"
77-
repoDir, err := testutil.SetupCustomTestRepo(t, "[email protected]:snyk-fixtures/shallow-goof-locked.git", "master", "", "shallow-goof-locked")
77+
78+
repoDir, err := testutil.SetupCustomTestRepo(t, expectedRepoUrl, "master", "", "shallow-goof-locked")
79+
require.NoError(t, err)
80+
81+
repo, err := git.PlainOpenWithOptions(repoDir, &git.PlainOpenOptions{
82+
DetectDotGit: true,
83+
})
7884
require.NoError(t, err)
7985

86+
config, err := repo.Config()
87+
assert.NoError(t, err)
88+
89+
for i := range config.Remotes["origin"].URLs {
90+
config.Remotes["origin"].URLs[i] = "[email protected]:snyk-fixtures/shallow-goof-locked.git"
91+
}
92+
93+
err = repo.SetConfig(config)
94+
assert.NoError(t, err)
95+
8096
// run method under test
8197
actualUrl, err := util.GetRepositoryUrl(repoDir)
8298
assert.NoError(t, err)

0 commit comments

Comments
 (0)