Skip to content

Commit

Permalink
fix: bubble up unexpected CLI errors
Browse files Browse the repository at this point in the history
  • Loading branch information
colethienes committed Jun 5, 2024
1 parent aa23cef commit c2293d7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion internal/argocd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func getAppDiff(ctx context.Context, opts appDiffOptions) (*string, error) {
if xe.ExitCode() == 1 {
return diff, nil
}
return nil, &model.DiffError{Reason: *diff}
}
return nil, &model.DiffError{Reason: *diff}
return nil, err
}
29 changes: 26 additions & 3 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ deployers:
name: my-argo-managed-cluster
endpoint: {{.argoAddr}}
authtoken: {{.argoAuthToken}}
- type: terraform
name: my-tf-managed-infra
workdir: ./terraform
vcs:
type: github
authtoken: {{.githubAuthToken}}
Expand Down Expand Up @@ -88,6 +85,32 @@ func TestComment(t *testing.T) {
require.Contains(t, *cmt.Body, "my_heart_is: full")
}

func TestComment_Failed(t *testing.T) {
// assemble
repo := "example-helm"
ctx := context.Background()
cmd := root.NewCommand()
cmd.SetArgs([]string{"comment",
"--repo", owner + "/" + repo,
"--revision", "7d2469c1f3a6e56b08f9492c8af39b0c53eb3024",
"--config", getConfig(ctx),
"--pull-number", "5",
})
out := new(bytes.Buffer)
cmd.SetOut(out)

// act
err := cmd.Execute()

// assert
require.NoError(t, err)
var comment model.Comment
err = json.Unmarshal(out.Bytes(), &comment)
require.NoError(t, err)
cmt := getGithubCommentOrDie(ctx, getGithubAuthTokenOrDie(), owner, repo, comment.ID)
require.Contains(t, *cmt.Body, "diff error:")
}

func getExecutor(ctx context.Context) (*infro.Executor, error) {
cfgString := getConfig(ctx)
var cfg infro.Config
Expand Down

0 comments on commit c2293d7

Please sign in to comment.