MCPcopy Create free account
hub / github.com/conforma/cli / AddStepsTo

Function AddStepsTo

acceptance/kubernetes/kubernetes.go:496–549  ·  view source on GitHub ↗

AddStepsTo adds cluster-related steps to the context

(sc *godog.ScenarioContext)

Source from the content-addressed store, hash-verified

494
495// AddStepsTo adds cluster-related steps to the context
496func AddStepsTo(sc *godog.ScenarioContext) {
497 sc.Step(`^a stub cluster running$`, startAndSetupState(stub.Start))
498 sc.Step(`^a cluster running$`, startAndSetupState(kind.Start))
499 sc.Step(`^a working namespace$`, createNamespace)
500 sc.Step(`^a snapshot artifact with content:$`, buildSnapshotArtifact)
501 sc.Step(`^policy configuration named "([^"]*)" with specification$`, createNamedPolicy)
502 sc.Step(`^a cluster policy with content:$`, createPolicy)
503 sc.Step(`^version ([\d.]+) of the task named "([^"]*)" is run with parameters:$`, runTask)
504 sc.Step(`^version ([\d.]+) of the task named "([^"]*)" with workspace "([^"]*)" is run with parameters:$`, runTaskWithWorkspace)
505 sc.Step(`^the task should succeed$`, theTaskShouldSucceed)
506 sc.Step(`^the task should fail$`, theTaskShouldFail)
507 sc.Step(`^an Snapshot named "([^"]*)" with specification$`, createNamedSnapshot)
508 sc.Step(`^an Snapshot named "([^"]*)" with (\d+) components signed with "([^"]*)" key$`, createNamedSnapshotWithManyComponents)
509 sc.Step(`^the task logs for step "([^"]*)" should match the snapshot$`, taskLogsShouldMatchTheSnapshot)
510 sc.Step(`^the task logs for step "([^"]*)" should contain "([^"]*)"$`, taskLogsShouldContain)
511 sc.Step("^the task logs for step \"([^\"]*)\" should contain `([^`]+)`$", taskLogsShouldContain)
512 sc.Step(`^the task env var for step "([^"]*)" named "([^"]*)" should be set to "([^"]*)"$`, stepEnvVarShouldBe)
513 sc.Step(`^the task results should match the snapshot$`, taskResultsShouldMatchTheSnapshot)
514 sc.Step(`^the task result "([^"]*)" should equal "([^"]*)"$`, taskResultShouldEqual)
515 sc.Step(`^policy configuration named "([^"]*)" with (\d+) policy sources from "([^"]*)"(?:, patched with)$`, createNamedPolicyWithManySources)
516 sc.Step(`^a namespace named "([^"]*)" exists$`, createNamedNamespace)
517 sc.Step(`^a ConfigMap "([^"]*)" in namespace "([^"]*)" with content:$`, createConfigMap)
518 // stop usage of the cluster once a test is done, godog will call this
519 // function on failure and on the last step, so more than once if the
520 // failure is not on the last step and once if there was no failure or the
521 // failure was on the last step
522 sc.After(func(ctx context.Context, sc *godog.Scenario, err error) (context.Context, error) {
523 if ctx.Value(stopStateKey) == nil {
524 ctx = context.WithValue(ctx, stopStateKey, true)
525 } else {
526 // we did this already
527 return ctx, nil
528 }
529
530 if !testenv.HasState[ClusterState](ctx) {
531 return ctx, nil
532 }
533
534 c := testenv.FetchState[ClusterState](ctx)
535 if c == nil {
536 return ctx, nil
537 }
538
539 if !c.Up(ctx) {
540 return ctx, nil
541 }
542
543 if c.cluster == nil {
544 return ctx, nil
545 }
546
547 return c.cluster.Stop(ctx)
548 })
549}
550
551func InitializeSuite(ctx context.Context, tsc *godog.TestSuiteContext) {
552 tsc.AfterSuite(func() {

Callers 1

initializeScenarioFunction · 0.92

Calls 3

startAndSetupStateFunction · 0.85
UpMethod · 0.65
StopMethod · 0.65

Tested by 1

initializeScenarioFunction · 0.74