AddStepsTo adds Gherkin steps to the godog ScenarioContext
(sc *godog.ScenarioContext)
| 314 | |
| 315 | // AddStepsTo adds Gherkin steps to the godog ScenarioContext |
| 316 | func AddStepsTo(sc *godog.ScenarioContext) { |
| 317 | sc.Step(`^stub git daemon running$`, startStubGitServer) |
| 318 | sc.Step(`^a git repository named "([^"]*)" with$`, createGitRepository) |
| 319 | |
| 320 | // removes all git repositories from the filesystem and terminates the container |
| 321 | sc.After(func(ctx context.Context, finished *godog.Scenario, scenarioErr error) (context.Context, error) { |
| 322 | if testenv.Persisted(ctx) { |
| 323 | return ctx, nil |
| 324 | } |
| 325 | |
| 326 | var state *gitState |
| 327 | if ctx, err := testenv.SetupState(ctx, &state); err != nil { |
| 328 | return ctx, err |
| 329 | } |
| 330 | |
| 331 | if state.Container != nil { |
| 332 | if err := state.Container.Terminate(ctx); err != nil { |
| 333 | logger, _ := log.LoggerFor(ctx) |
| 334 | logger.Warnf("failed to terminate git container: %v", err) |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | if state.RepositoriesDir != "" { |
| 339 | os.RemoveAll(state.RepositoriesDir) |
| 340 | } |
| 341 | |
| 342 | return ctx, nil |
| 343 | }) |
| 344 | } |