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

Make it easier to handle expected failures #83

Open
blampe opened this issue Apr 24, 2024 · 2 comments
Open

Make it easier to handle expected failures #83

blampe opened this issue Apr 24, 2024 · 2 comments
Labels
kind/enhancement Improvements or new features

Comments

@blampe
Copy link
Contributor

blampe commented Apr 24, 2024

I have a situation where I expect an update to fail and I'd like to assert that it does. Unfortunately errors are always treated as fatal:

result, err := a.currentStack.Up(a.ctx, opts...)
if err != nil {
a.fatalf("failed to deploy: %s", err)
}

It would be really nice if we returned result, err here instead, although that would be a breaking change.

We should at least be able to have an option ExpectFailure and then use that to inform the t.fatal? Although that will need to update the auto API's options.

// Ideal
up, err := test.Up()
assert.Error(t, err)

// Also OK
up := test.Up(optup.ExpectFailure())

@VenelinMartinov points out a workaround: up, err := test.CurrentStack().Up(ctx).

@blampe blampe added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team labels Apr 24, 2024
@blampe blampe changed the title Return errors for expected failures Expected failures Apr 24, 2024
@EronWright
Copy link
Contributor

EronWright commented Apr 25, 2024

Suggestion: add an ExpectFailure flag to the Up options, and fail/succeed accordingly.

@mjeffryes mjeffryes removed the needs-triage Needs attention from the triage team label Apr 25, 2024
@danielrbradley
Copy link
Member

Returning result, err would reduce the clarity of tests as they'd have to now contain error handling for every step. This would be equivilent to just using the AutomationAPI directly without the test framework.

Another option instead of disabling the assert would be to present an alternative method for operations we expect might fail - perhaps something like upResult, err := test.TryUp(). I'm not sure if Try... is a usual convention in Go, perhaps there's another ideom that would do the same job.

@danielrbradley danielrbradley changed the title Expected failures Make it easier to handle expected failures Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

4 participants