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 finalizing allure reports. #179

Merged
merged 1 commit into from Aug 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
40 changes: 18 additions & 22 deletions runner/runner_testing.go
Expand Up @@ -29,12 +29,12 @@ type Aerospike struct {
}

type RunWithTestingParams struct {
Server *httptest.Server
TestsDir string
Mocks *mocks.Mocks
FixturesDir string
DB *sql.DB
Aerospike Aerospike
Server *httptest.Server
TestsDir string
Mocks *mocks.Mocks
FixturesDir string
DB *sql.DB
Aerospike Aerospike
// If DB parameter present, used to recognize type of database, if not set, by default uses Postgres
DbType fixtures.DbType
EnvFilePath string
Expand All @@ -60,7 +60,7 @@ func RunWithTesting(t *testing.T, params *RunWithTestingParams) {
debug := os.Getenv("GONKEY_DEBUG") != ""

var fixturesLoader fixtures.Loader
if params.DB != nil || params.Aerospike.Client != nil || params.FixtureLoader != nil {
if params.DB != nil || params.Aerospike.Client != nil || params.FixtureLoader != nil {
fixturesLoader = fixtures.NewLoader(&fixtures.Config{
Location: params.FixturesDir,
DB: params.DB,
Expand All @@ -73,7 +73,17 @@ func RunWithTesting(t *testing.T, params *RunWithTestingParams) {

runner := initRunner(params, mocksLoader, fixturesLoader)

setupOutputs(runner, params, t)
if params.OutputFunc != nil {
runner.AddOutput(params.OutputFunc)
} else {
runner.AddOutput(testingOutput.NewOutput(t))
}

if os.Getenv("GONKEY_ALLURE_DIR") != "" {
allureOutput := allure_report.NewOutput("Gonkey", os.Getenv("GONKEY_ALLURE_DIR"))
defer allureOutput.Finalize()
runner.AddOutput(allureOutput)
}

addCheckers(runner, params)

Expand Down Expand Up @@ -110,17 +120,3 @@ func addCheckers(runner *Runner, params *RunWithTestingParams) {

runner.AddCheckers(params.Checkers...)
}

func setupOutputs(r *Runner, params *RunWithTestingParams, t *testing.T) {
if params.OutputFunc != nil {
r.AddOutput(params.OutputFunc)
} else {
r.AddOutput(testingOutput.NewOutput(t))
}

if os.Getenv("GONKEY_ALLURE_DIR") != "" {
allureOutput := allure_report.NewOutput("Gonkey", os.Getenv("GONKEY_ALLURE_DIR"))
defer allureOutput.Finalize()
r.AddOutput(allureOutput)
}
}