AddStepsTo adds Gherkin steps to the godog ScenarioContext
(sc *godog.ScenarioContext)
| 324 | |
| 325 | // AddStepsTo adds Gherkin steps to the godog ScenarioContext |
| 326 | func AddStepsTo(sc *godog.ScenarioContext) { |
| 327 | sc.Step(`^stub registry running$`, startStubRegistry) |
| 328 | sc.Step(`^registry image "([^"]*)" should contain a layer with$`, assertImageContent) |
| 329 | |
| 330 | sc.After(func(ctx context.Context, finished *godog.Scenario, scenarioErr error) (context.Context, error) { |
| 331 | if testenv.Persisted(ctx) { |
| 332 | return ctx, nil |
| 333 | } |
| 334 | |
| 335 | if !testenv.HasState[registryState](ctx) { |
| 336 | return ctx, nil |
| 337 | } |
| 338 | |
| 339 | state := testenv.FetchState[registryState](ctx) |
| 340 | if state.Container != nil { |
| 341 | if err := state.Container.Terminate(ctx); err != nil { |
| 342 | logger, _ := log.LoggerFor(ctx) |
| 343 | logger.Warnf("failed to terminate registry container: %v", err) |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | return ctx, nil |
| 348 | }) |
| 349 | } |