GODT-219: Update to godog v0.12.1

This commit is contained in:
Jakub
2021-09-06 16:22:35 +02:00
parent 22d2bcc21d
commit e0113ec267
27 changed files with 348 additions and 103 deletions

View File

@ -27,11 +27,10 @@ import (
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
"github.com/ProtonMail/proton-bridge/test/accounts"
"github.com/cucumber/godog"
"github.com/cucumber/godog/gherkin"
"github.com/stretchr/testify/assert"
)
func APIChecksFeatureContext(s *godog.Suite) {
func APIChecksFeatureContext(s *godog.ScenarioContext) {
s.Step(`^API endpoint "([^"]*)" is called$`, apiIsCalled)
s.Step(`^API endpoint "([^"]*)" is called with$`, apiIsCalledWith)
s.Step(`^API endpoint "([^"]*)" is not called$`, apiIsNotCalled)
@ -52,14 +51,14 @@ func apiIsCalled(endpoint string) error {
return nil
}
func apiIsCalledWith(endpoint string, data *gherkin.DocString) error {
func apiIsCalledWith(endpoint string, data *godog.DocString) error {
if !apiIsCalledWithHelper(endpoint, data.Content) {
return fmt.Errorf("%s was not called with %s", endpoint, data.Content)
}
return nil
}
func apiIsCalledWithRegex(endpoint string, data *gherkin.DocString) error {
func apiIsCalledWithRegex(endpoint string, data *godog.DocString) error {
match, err := apiIsCalledWithHelperRegex(endpoint, data.Content)
if err != nil {
return err
@ -77,7 +76,7 @@ func apiIsNotCalled(endpoint string) error {
return nil
}
func apiIsNotCalledWith(endpoint string, data *gherkin.DocString) error {
func apiIsNotCalledWith(endpoint string, data *godog.DocString) error {
if apiIsCalledWithHelper(endpoint, data.Content) {
return fmt.Errorf("%s was called with %s", endpoint, data.Content)
}
@ -100,7 +99,7 @@ func apiIsCalledWithHelperRegex(endpoint string, content string) (bool, error) {
return ctx.GetPMAPIController().WasCalledRegex(method, path, request)
}
func messageIsSentWithAPICall(data *gherkin.DocString) error {
func messageIsSentWithAPICall(data *godog.DocString) error {
endpoint := "POST /mail/v4/messages"
if err := apiIsCalledWith(endpoint, data); err != nil {
return err
@ -114,7 +113,7 @@ func messageIsSentWithAPICall(data *gherkin.DocString) error {
return nil
}
func packagesAreSentWithAPICall(data *gherkin.DocString) error {
func packagesAreSentWithAPICall(data *godog.DocString) error {
endpoint := "POST /mail/v4/messages/.+$"
if err := apiIsCalledWithRegex(endpoint, data); err != nil {
return err
@ -179,11 +178,11 @@ func apiMailboxForAddressOfUserHasNumberOfMessages(mailboxName, bddAddressID, bd
return nil
}
func apiMailboxForUserHasMessages(mailboxName, bddUserID string, messages *gherkin.DataTable) error {
func apiMailboxForUserHasMessages(mailboxName, bddUserID string, messages *godog.Table) error {
return apiMailboxForAddressOfUserHasMessages(mailboxName, "", bddUserID, messages)
}
func apiMailboxForAddressOfUserHasMessages(mailboxName, bddAddressID, bddUserID string, messages *gherkin.DataTable) error {
func apiMailboxForAddressOfUserHasMessages(mailboxName, bddAddressID, bddUserID string, messages *godog.Table) error {
account := ctx.GetTestAccountWithAddress(bddUserID, bddAddressID)
if account == nil {
return godog.ErrPending