Update tests and examples with up to date API (#460)
Этот коммит содержится в:
родитель
c95871f3ce
коммит
5efecbaf10
6 изменённых файлов: 22 добавлений и 6 удалений
|
@ -13,6 +13,7 @@ This document is formatted according to the principles of [Keep A CHANGELOG](htt
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Changed underlying cobra command setup to return errors instead of calling `os.Exit` directly to enable simpler testing. ([454](https://github.com/cucumber/godog/pull/454) - [mxygem])
|
- Changed underlying cobra command setup to return errors instead of calling `os.Exit` directly to enable simpler testing. ([454](https://github.com/cucumber/godog/pull/454) - [mxygem])
|
||||||
|
- Remove use of deprecated methods from `_examples`. ([460](https://github.com/cucumber/godog/pull/460) - [ricardogarfe])
|
||||||
|
|
||||||
## [v0.12.4]
|
## [v0.12.4]
|
||||||
|
|
||||||
|
|
|
@ -91,6 +91,7 @@ Now we can implemented steps, since we know what behavior we expect:
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -159,7 +160,10 @@ func (a *apiFeature) theResponseShouldMatchJSON(body *godog.DocString) error {
|
||||||
func InitializeScenario(s *godog.ScenarioContext) {
|
func InitializeScenario(s *godog.ScenarioContext) {
|
||||||
api := &apiFeature{}
|
api := &apiFeature{}
|
||||||
|
|
||||||
s.BeforeScenario(api.resetResponse)
|
ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
|
||||||
|
api.resetResponse(sc)
|
||||||
|
return ctx, nil
|
||||||
|
})
|
||||||
|
|
||||||
s.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo)
|
s.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo)
|
||||||
s.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
|
s.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -73,8 +74,10 @@ func (a *apiFeature) theResponseShouldMatchJSON(body *godog.DocString) (err erro
|
||||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||||
api := &apiFeature{}
|
api := &apiFeature{}
|
||||||
|
|
||||||
ctx.BeforeScenario(api.resetResponse)
|
ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
|
||||||
|
api.resetResponse(sc)
|
||||||
|
return ctx, nil
|
||||||
|
})
|
||||||
ctx.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo)
|
ctx.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo)
|
||||||
ctx.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
|
ctx.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
|
||||||
ctx.Step(`^the response should match json:$`, api.theResponseShouldMatchJSON)
|
ctx.Step(`^the response should match json:$`, api.theResponseShouldMatchJSON)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -63,8 +64,9 @@ func thereShouldBeNoneRemaining() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||||
ctx.BeforeScenario(func(*godog.Scenario) {
|
ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
|
||||||
Godogs = 0 // clean the state before every scenario
|
Godogs = 0 // clean the state before every scenario
|
||||||
|
return ctx, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
ctx.Step(`^there are (\d+) godogs$`, thereAreGodogs)
|
ctx.Step(`^there are (\d+) godogs$`, thereAreGodogs)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -125,7 +126,10 @@ func (a *apiFeature) thereAreUsers(users *godog.Table) error {
|
||||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||||
api := &apiFeature{}
|
api := &apiFeature{}
|
||||||
|
|
||||||
ctx.BeforeScenario(api.resetResponse)
|
ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
|
||||||
|
api.resetResponse(sc)
|
||||||
|
return ctx, nil
|
||||||
|
})
|
||||||
|
|
||||||
ctx.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo)
|
ctx.Step(`^I send "(GET|POST|PUT|DELETE)" request to "([^"]*)"$`, api.iSendrequestTo)
|
||||||
ctx.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
|
ctx.Step(`^the response code should be (\d+)$`, api.theResponseCodeShouldBe)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -55,8 +56,9 @@ func InitializeTestSuite(ctx *godog.TestSuiteContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitializeScenario(ctx *godog.ScenarioContext) {
|
func InitializeScenario(ctx *godog.ScenarioContext) {
|
||||||
ctx.BeforeScenario(func(*godog.Scenario) {
|
ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
|
||||||
Godogs = 0 // clean the state before every scenario
|
Godogs = 0 // clean the state before every scenario
|
||||||
|
return ctx, nil
|
||||||
})
|
})
|
||||||
|
|
||||||
ctx.Step(`^there are (\d+) godogs$`, thereAreGodogs)
|
ctx.Step(`^there are (\d+) godogs$`, thereAreGodogs)
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче