Skip to content

Commit

Permalink
Add test for #487
Browse files Browse the repository at this point in the history
  • Loading branch information
wichert committed Jul 22, 2022
1 parent a4846a7 commit 525bb93
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions suite_context_test.go
Expand Up @@ -59,6 +59,15 @@ func InitializeScenario(ctx *ScenarioContext) {
ctx.Step(`^the following steps? should be (passed|failed|skipped|undefined|pending):`, tc.followingStepsShouldHave)
ctx.Step(`^the undefined step snippets should be:$`, tc.theUndefinedStepSnippetsShouldBe)

ctx.Step(`^I return a context from a step$`, tc.iReturnAContextFromAStep)
ctx.Step(`^I should see the context in the next step$`, tc.iShouldSeeTheContextInTheNextStep)
ctx.Step(`^I can see contexts passed in multisteps$`, func() Steps {
return Steps{
"I return a context from a step",
"I should see the context in the next step",
}
})

// event stream
ctx.Step(`^the following events should be fired:$`, tc.thereShouldBeEventsFired)

Expand Down Expand Up @@ -339,6 +348,21 @@ func (tc *godogFeaturesScenario) theUndefinedStepSnippetsShouldBe(body *DocStrin
return nil
}

func (tc *godogFeaturesScenario) iReturnAContextFromAStep(ctx context.Context) (context.Context, error) {
return context.WithValue(ctx, "key", "value"), nil
}

func (tc *godogFeaturesScenario) iShouldSeeTheContextInTheNextStep(ctx context.Context) error {
value, ok := ctx.Value("key").(string)
if !ok {
return errors.New("context does not contain our key")
}
if value != "value" {
return errors.New("context has the wrong value for our key")
}
return nil
}

func (tc *godogFeaturesScenario) followingStepsShouldHave(status string, steps *DocString) error {
var expected = strings.Split(steps.Content, "\n")
var actual, unmatched, matched []string
Expand Down

0 comments on commit 525bb93

Please sign in to comment.