Fix git clone integration test for non-existing repo (#610)

## Changes
This PR changes the integration test to just check an error is returned
rather than asserting specific text is present in the error. This is
required because the error returned can be different based on whether
git ssh keys have been setup.
This commit is contained in:
shreyas-goenka 2023-07-27 15:51:57 +02:00 committed by GitHub
parent e4b66833dd
commit 2f4bf844fc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View File

@ -53,11 +53,12 @@ func TestAccGitCloneWithOnlyRepoNameOnAlternateBranch(t *testing.T) {
assert.Contains(t, string(b), "dais-2022")
}
func TestAccGitCloneRepositoryDoesNotExist(t *testing.T) {
func TestAccGitCloneErrorsWhenRepositoryDoesNotExist(t *testing.T) {
t.Log(GetEnvOrSkipTest(t, "CLOUD_ENV"))
tmpDir := t.TempDir()
err := git.Clone(context.Background(), "doesnot-exist", "", tmpDir)
assert.Contains(t, err.Error(), `repository 'https://github.com/databricks/doesnot-exist/' not found`)
err := git.Clone(context.Background(), "https://github.com/monalisa/doesnot-exist.git", "", tmpDir)
// Expect the error to originate from shelling out to `git clone`
assert.ErrorContains(t, err, "git clone failed:")
}

View File

@ -60,7 +60,7 @@ func Clone(ctx context.Context, url, reference, targetPath string) error {
return fmt.Errorf("please install git CLI to clone a repository: %w", err)
}
if err != nil {
return err
return fmt.Errorf("git clone failed: %w", err)
}
// wait for git clone to complete