Skip to content

Commit

Permalink
test: fix git clone tests for ssh (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
teodora-sandu committed May 15, 2024
1 parent 1d45bef commit 6dcc4f2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion internal/util/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,25 @@ func Test_GetRepositoryUrl_repo_without_credentials(t *testing.T) {
func Test_GetRepositoryUrl_repo_with_ssh(t *testing.T) {
// check out a repo and prepare its config to contain credentials in the URL
expectedRepoUrl := "https://github.com/snyk-fixtures/shallow-goof-locked.git"
repoDir, err := testutil.SetupCustomTestRepo(t, "git@github.com:snyk-fixtures/shallow-goof-locked.git", "master", "", "shallow-goof-locked")

repoDir, err := testutil.SetupCustomTestRepo(t, expectedRepoUrl, "master", "", "shallow-goof-locked")
require.NoError(t, err)

repo, err := git.PlainOpenWithOptions(repoDir, &git.PlainOpenOptions{
DetectDotGit: true,
})
require.NoError(t, err)

config, err := repo.Config()
assert.NoError(t, err)

for i := range config.Remotes["origin"].URLs {
config.Remotes["origin"].URLs[i] = "git@github.com:snyk-fixtures/shallow-goof-locked.git"
}

err = repo.SetConfig(config)
assert.NoError(t, err)

// run method under test
actualUrl, err := util.GetRepositoryUrl(repoDir)
assert.NoError(t, err)
Expand Down

0 comments on commit 6dcc4f2

Please sign in to comment.