Skip to content

Commit

Permalink
Deprecate RegisterContext
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm committed Jan 22, 2024
1 parent 0a5f620 commit 8a7b1f1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
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 @@ type tHelper interface {
}

// 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

0 comments on commit 8a7b1f1

Please sign in to comment.