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

Function initializeScenario

acceptance/acceptance_test.go:125–174  ·  view source on GitHub ↗

initializeScenario adds all steps and registers all hooks to the provided godog.ScenarioContext

(sc *godog.ScenarioContext)

Source from the content-addressed store, hash-verified

123// initializeScenario adds all steps and registers all hooks to the
124// provided godog.ScenarioContext
125func initializeScenario(sc *godog.ScenarioContext) {
126 cli.AddStepsTo(sc)
127 crypto.AddStepsTo(sc)
128 git.AddStepsTo(sc)
129 image.AddStepsTo(sc)
130 kubernetes.AddStepsTo(sc)
131 registry.AddStepsTo(sc)
132 rekor.AddStepsTo(sc)
133 tekton.AddStepsTo(sc)
134 wiremock.AddStepsTo(sc)
135 pipeline.AddStepsTo(sc)
136 conftest.AddStepsTo(sc)
137 tuf.AddStepsTo(sc)
138 vsa.AddStepsTo(sc)
139
140 sc.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
141 logger, ctx := log.LoggerFor(ctx)
142 logger.Name(sc.Name)
143
144 return context.WithValue(ctx, testenv.Scenario, sc), nil
145 })
146
147 sc.After(func(ctx context.Context, scenario *godog.Scenario, scenarioErr error) (context.Context, error) {
148 logger, ctx := log.LoggerFor(ctx)
149
150 logFile := logger.LogFile()
151
152 _, persistErr := testenv.Persist(ctx)
153 logger.Close()
154
155 if scenarioErr != nil {
156 tracker.addFailure(scenario.Name, scenario.Uri, logFile, scenarioErr)
157 } else if persistErr != nil {
158 tracker.addFailure(scenario.Name, scenario.Uri, logFile, persistErr)
159 } else {
160 os.Remove(logFile)
161 }
162
163 if tty, err := os.OpenFile("/dev/tty", os.O_WRONLY, 0); err == nil {
164 if scenarioErr != nil || persistErr != nil {
165 fmt.Fprintf(tty, "✗ FAILED: %s (%s)\n", scenario.Name, scenario.Uri)
166 } else {
167 fmt.Fprintf(tty, "✓ PASSED: %s (%s)\n", scenario.Name, scenario.Uri)
168 }
169 tty.Close()
170 }
171
172 return ctx, persistErr
173 })
174}
175
176func initializeSuite(ctx context.Context) func(*godog.TestSuiteContext) {
177 return func(tsc *godog.TestSuiteContext) {

Callers

nothing calls this directly

Calls 15

AddStepsToFunction · 0.92
AddStepsToFunction · 0.92
AddStepsToFunction · 0.92
AddStepsToFunction · 0.92
AddStepsToFunction · 0.92
AddStepsToFunction · 0.92
AddStepsToFunction · 0.92
AddStepsToFunction · 0.92
AddStepsToFunction · 0.92
AddStepsToFunction · 0.92
AddStepsToFunction · 0.92
AddStepsToFunction · 0.92

Tested by

no test coverage detected