Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate RegisterContext #17

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions features/bootstrap/godog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ func TestIntegration(t *testing.T) {
)

RunSuite(t, "..", func(_ *testing.T, ctx *godog.ScenarioContext) {
m.RegisterContext(ctx)
w.registerContext(ctx)
m.RegisterSteps(ctx)
w.RegisterSteps(ctx)
})
}

Expand Down
4 changes: 2 additions & 2 deletions features/bootstrap/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ type writer struct {
console *expect.Console
}

func (w *writer) registerContext(ctx *godog.ScenarioContext) {
ctx.Step(`write to console:`, func(s *godog.DocString) error {
func (w *writer) RegisterSteps(s *godog.ScenarioContext) {
s.Step(`write to console:`, func(s *godog.DocString) error {
_, err := w.console.Write([]byte(s.Content))

return err
Expand Down
17 changes: 12 additions & 5 deletions manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,28 @@
}

// RegisterContext register console Manager to test context.
func (m *Manager) RegisterContext(ctx *godog.ScenarioContext) {
ctx.Before(func(_ context.Context, sc *godog.Scenario) (context.Context, error) {
//
// Deprecated: Use Manager.RegisterSteps instead.
func (m *Manager) RegisterContext(s *godog.ScenarioContext) {
m.RegisterSteps(s)

Check warning on line 55 in manager.go

View check run for this annotation

Codecov / codecov/patch

manager.go#L54-L55

Added lines #L54 - L55 were not covered by tests
}

// RegisterSteps register console Manager to test context.
func (m *Manager) RegisterSteps(s *godog.ScenarioContext) {
s.Before(func(_ context.Context, sc *godog.Scenario) (context.Context, error) {
m.NewConsole(sc)

return nil, nil
})

ctx.After(func(_ context.Context, sc *godog.Scenario, _ error) (context.Context, error) {
s.After(func(_ context.Context, sc *godog.Scenario, _ error) (context.Context, error) {
m.CloseConsole(sc)

return nil, nil
})

ctx.Step(`console output is:`, m.isConsoleOutput)
ctx.Step(`console output matches:`, m.matchConsoleOutput)
s.Step(`console output is:`, m.isConsoleOutput)
s.Step(`console output matches:`, m.matchConsoleOutput)
}

func (m *Manager) session() *session {
Expand Down
Loading