Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 9 commits into from
Jul 27, 2023
7 changes: 4 additions & 3 deletions internal/git_clone_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
}
2 changes: 1 addition & 1 deletion libs/git/clone.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down