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

Add DeployerWithPostTester interface #104

Merged
merged 1 commit into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,22 @@ func RealMain(opts types.Options, d types.Deployer, tester types.Tester) (result

}
test.SetEnv(envsForTester...)

var testErr error
if !opts.SkipTestJUnitReport() {
return writer.WrapStep("Test", test.Run)
testErr = writer.WrapStep("Test", test.Run)
} else {
testErr = test.Run()
}
return test.Run()
}

if dWithPostTester, ok := d.(types.DeployerWithPostTester); ok {
if err := dWithPostTester.PostTest(testErr); err != nil {
return err
}
}
if testErr != nil {
return testErr
}
}
return nil
}
10 changes: 10 additions & 0 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ type DeployerWithProvider interface {
Provider() string
}

// DeployerWithPostTester adds the ability to define after-test behavior
// based on the results of the test.
type DeployerWithPostTester interface {
Deployer

// PostTest runs after the tester completes.
// testErr is the error returned from the tester's Run()
PostTest(testErr error) error
}

// Tester defines the "interface" between kubetest2 and a tester
// The tester is executed as a separate binary during the Test() phase
type Tester struct {
Expand Down