forked from Silverfish/proton-bridge
GODT-219: Update to godog v0.12.1
This commit is contained in:
@ -14,7 +14,7 @@ check-go:
|
||||
check-godog:
|
||||
@which godog || $(MAKE) install-godog
|
||||
install-godog: check-go
|
||||
go get github.com/cucumber/godog/cmd/godog@v0.8.1
|
||||
go get github.com/cucumber/godog/cmd/godog@v0.12.1
|
||||
|
||||
test: test-bridge test-ie
|
||||
test-bridge: FEATURES ?= features/bridge
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
func APIActionsFeatureContext(s *godog.Suite) {
|
||||
func APIActionsFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^the internet connection is lost$`, theInternetConnectionIsLost)
|
||||
s.Step(`^the internet connection is restored$`, theInternetConnectionIsRestored)
|
||||
s.Step(`^(\d+) second[s]? pass$`, secondsPass)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
func APISetupFeatureContext(s *godog.Suite) {
|
||||
func APISetupFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^there is no internet connection$`, thereIsNoInternetConnection)
|
||||
}
|
||||
|
||||
|
||||
@ -18,9 +18,10 @@
|
||||
package tests
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/test/context"
|
||||
testContext "github.com/ProtonMail/proton-bridge/test/context"
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
@ -28,12 +29,14 @@ const (
|
||||
timeFormat = "2006-01-02T15:04:05"
|
||||
)
|
||||
|
||||
func FeatureContext(s *godog.Suite) {
|
||||
s.BeforeSuite(context.BeforeRun)
|
||||
s.AfterSuite(context.AfterRun)
|
||||
func SuiteInitializer(s *godog.TestSuiteContext) {
|
||||
s.BeforeSuite(testContext.BeforeRun)
|
||||
s.AfterSuite(testContext.AfterRun)
|
||||
}
|
||||
|
||||
s.BeforeScenario(beforeScenario)
|
||||
s.AfterScenario(afterScenario)
|
||||
func ScenarioInitializer(s *godog.ScenarioContext) {
|
||||
s.Before(beforeScenario)
|
||||
s.After(afterScenario)
|
||||
|
||||
APIActionsFeatureContext(s)
|
||||
APIChecksFeatureContext(s)
|
||||
@ -66,16 +69,16 @@ func FeatureContext(s *godog.Suite) {
|
||||
UsersChecksFeatureContext(s)
|
||||
}
|
||||
|
||||
var ctx *context.TestContext //nolint[gochecknoglobals]
|
||||
var ctx *testContext.TestContext //nolint[gochecknoglobals]
|
||||
|
||||
func beforeScenario(scenario interface{}) {
|
||||
// bridge or ie. With godog 0.10.x and later it can be determined from
|
||||
// scenario.Uri and its file location.
|
||||
func beforeScenario(scenarioCtx context.Context, _ *godog.Scenario) (context.Context, error) {
|
||||
// NOTE(GODT-219) It would be possible to optimised the usage of godog with our context.
|
||||
app := os.Getenv("TEST_APP")
|
||||
ctx = context.New(app)
|
||||
ctx = testContext.New(app)
|
||||
return scenarioCtx, nil
|
||||
}
|
||||
|
||||
func afterScenario(scenario interface{}, err error) {
|
||||
func afterScenario(scenarioCtx context.Context, _ *godog.Scenario, err error) (context.Context, error) {
|
||||
if err != nil {
|
||||
for _, user := range ctx.GetUsers().GetUsers() {
|
||||
store := user.GetStore()
|
||||
@ -88,4 +91,6 @@ func afterScenario(scenario interface{}, err error) {
|
||||
if err != nil {
|
||||
ctx.GetPMAPIController().PrintCalls()
|
||||
}
|
||||
|
||||
return scenarioCtx, err
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
func BridgeActionsFeatureContext(s *godog.Suite) {
|
||||
func BridgeActionsFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^bridge starts$`, bridgeStarts)
|
||||
s.Step(`^bridge syncs "([^"]*)"$`, bridgeSyncsUser)
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
a "github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func CommonChecksFeatureContext(s *godog.Suite) {
|
||||
func CommonChecksFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^last response is "([^"]*)"$`, lastResponseIs)
|
||||
}
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
func IMAPActionsAuthFeatureContext(s *godog.Suite) {
|
||||
func IMAPActionsAuthFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^IMAP client authenticates "([^"]*)"$`, imapClientAuthenticates)
|
||||
s.Step(`^IMAP client "([^"]*)" authenticates "([^"]*)"$`, imapClientNamedAuthenticates)
|
||||
s.Step(`^IMAP client authenticates "([^"]*)" with address "([^"]*)"$`, imapClientAuthenticatesWithAddress)
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
func IMAPActionsMailboxFeatureContext(s *godog.Suite) {
|
||||
func IMAPActionsMailboxFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^IMAP client creates mailbox "([^"]*)"$`, imapClientCreatesMailbox)
|
||||
s.Step(`^IMAP client renames mailbox "([^"]*)" to "([^"]*)"$`, imapClientRenamesMailboxTo)
|
||||
s.Step(`^IMAP client deletes mailbox "([^"]*)"$`, imapClientDeletesMailbox)
|
||||
|
||||
@ -23,11 +23,10 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/gherkin"
|
||||
"golang.org/x/net/html/charset"
|
||||
)
|
||||
|
||||
func IMAPActionsMessagesFeatureContext(s *godog.Suite) {
|
||||
func IMAPActionsMessagesFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^IMAP client sends command "([^"]*)"$`, imapClientSendsCommand)
|
||||
s.Step(`^IMAP client fetches "([^"]*)"$`, imapClientFetches)
|
||||
s.Step(`^IMAP client fetches header(?:s)? of "([^"]*)"$`, imapClientFetchesHeader)
|
||||
@ -161,11 +160,11 @@ func imapClientsMoveMessageSeqOfUserFromToByAppendAndDelete(sourceIMAPClient, ta
|
||||
return nil
|
||||
}
|
||||
|
||||
func imapClientCreatesMessage(mailboxName string, message *gherkin.DocString) error {
|
||||
func imapClientCreatesMessage(mailboxName string, message *godog.DocString) error {
|
||||
return imapClientCreatesMessageWithEncoding(mailboxName, "utf8", message)
|
||||
}
|
||||
|
||||
func imapClientCreatesMessageWithEncoding(mailboxName, encodingName string, message *gherkin.DocString) error {
|
||||
func imapClientCreatesMessageWithEncoding(mailboxName, encodingName string, message *godog.DocString) error {
|
||||
encoding, _ := charset.Lookup(encodingName)
|
||||
|
||||
msg := message.Content
|
||||
@ -313,11 +312,11 @@ func imapClientNamedExpungeByUID(imapClient, uids string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func imapClientSendsID(data *gherkin.DocString) error {
|
||||
func imapClientSendsID(data *godog.DocString) error {
|
||||
return imapClientNamedSendsID("imap", data)
|
||||
}
|
||||
|
||||
func imapClientNamedSendsID(imapClient string, data *gherkin.DocString) error {
|
||||
func imapClientNamedSendsID(imapClient string, data *godog.DocString) error {
|
||||
res := ctx.GetIMAPClient(imapClient).ID(data.Content)
|
||||
ctx.SetIMAPLastResponse(imapClient, res)
|
||||
return nil
|
||||
|
||||
@ -26,7 +26,7 @@ import (
|
||||
"github.com/emersion/go-imap"
|
||||
)
|
||||
|
||||
func IMAPChecksFeatureContext(s *godog.Suite) {
|
||||
func IMAPChecksFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^IMAP response is "([^"]*)"$`, imapResponseIs)
|
||||
s.Step(`^IMAP response to "([^"]*)" is "([^"]*)"$`, imapResponseNamedIs)
|
||||
s.Step(`^IMAP response contains "([^"]*)"$`, imapResponseContains)
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
func IMAPSetupFeatureContext(s *godog.Suite) {
|
||||
func IMAPSetupFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^there is IMAP client logged in as "([^"]*)"$`, thereIsIMAPClientLoggedInAs)
|
||||
s.Step(`^there is IMAP client "([^"]*)" logged in as "([^"]*)"$`, thereIsIMAPClientNamedLoggedInAs)
|
||||
s.Step(`^there is IMAP client logged in as "([^"]*)" with address "([^"]*)"$`, thereIsIMAPClientLoggedInAsWithAddress)
|
||||
|
||||
@ -33,7 +33,7 @@ var opt = godog.Options{ //nolint[gochecknoglobals]
|
||||
}
|
||||
|
||||
func init() { //nolint[gochecknoinits]
|
||||
godog.BindFlags("godog.", flag.CommandLine, &opt)
|
||||
godog.BindCommandLineFlags("godog.", &opt)
|
||||
|
||||
// This would normally be done using ldflags but `godog` command doesn't support that.
|
||||
constants.Version = os.Getenv("BRIDGE_VERSION")
|
||||
@ -43,9 +43,12 @@ func TestMain(m *testing.M) {
|
||||
flag.Parse()
|
||||
opt.Paths = flag.Args()
|
||||
|
||||
status := godog.RunWithOptions("godogs", func(s *godog.Suite) {
|
||||
FeatureContext(s)
|
||||
}, opt)
|
||||
status := godog.TestSuite{
|
||||
Name: "bridge-integration-tests",
|
||||
TestSuiteInitializer: SuiteInitializer,
|
||||
ScenarioInitializer: ScenarioInitializer,
|
||||
Options: &opt,
|
||||
}.Run()
|
||||
|
||||
if st := m.Run(); st > status {
|
||||
status = st
|
||||
|
||||
@ -21,10 +21,9 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/gherkin"
|
||||
)
|
||||
|
||||
func SMTPActionsAuthFeatureContext(s *godog.Suite) {
|
||||
func SMTPActionsAuthFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^SMTP client authenticates "([^"]*)"$`, smtpClientAuthenticates)
|
||||
s.Step(`^SMTP client "([^"]*)" authenticates "([^"]*)"$`, smtpClientNamedAuthenticates)
|
||||
s.Step(`^SMTP client authenticates "([^"]*)" with address "([^"]*)"$`, smtpClientAuthenticatesWithAddress)
|
||||
@ -91,19 +90,19 @@ func smtpClientLogsOut() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func smtpClientSendsMessage(message *gherkin.DocString) error {
|
||||
func smtpClientSendsMessage(message *godog.DocString) error {
|
||||
return smtpClientNamedSendsMessage("smtp", message)
|
||||
}
|
||||
|
||||
func smtpClientNamedSendsMessage(clientID string, message *gherkin.DocString) error {
|
||||
func smtpClientNamedSendsMessage(clientID string, message *godog.DocString) error {
|
||||
return smtpClientNamedSendsMessageWithBCC(clientID, "", message)
|
||||
}
|
||||
|
||||
func smtpClientSendsMessageWithBCC(bcc string, message *gherkin.DocString) error {
|
||||
func smtpClientSendsMessageWithBCC(bcc string, message *godog.DocString) error {
|
||||
return smtpClientNamedSendsMessageWithBCC("smtp", bcc, message)
|
||||
}
|
||||
|
||||
func smtpClientNamedSendsMessageWithBCC(clientID, bcc string, message *gherkin.DocString) error {
|
||||
func smtpClientNamedSendsMessageWithBCC(clientID, bcc string, message *godog.DocString) error {
|
||||
res := ctx.GetSMTPClient(clientID).SendMail(strings.NewReader(message.Content), bcc)
|
||||
ctx.SetSMTPLastResponse(clientID, res)
|
||||
return nil
|
||||
@ -112,7 +111,7 @@ func smtpClientNamedSendsMessageWithBCC(clientID, bcc string, message *gherkin.D
|
||||
func smtpClientSendsCommand(command string) error {
|
||||
return smtpClientNamedSendsCommand("smtp", command)
|
||||
}
|
||||
func smtpClientSendsCommandMultiline(command *gherkin.DocString) error {
|
||||
func smtpClientSendsCommandMultiline(command *godog.DocString) error {
|
||||
return smtpClientNamedSendsCommand("smtp", command.Content)
|
||||
}
|
||||
func smtpClientNamedSendsCommand(clientName, command string) error {
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
func SMTPChecksFeatureContext(s *godog.Suite) {
|
||||
func SMTPChecksFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^SMTP response is "([^"]*)"$`, smtpResponseIs)
|
||||
s.Step(`^SMTP response to "([^"]*)" is "([^"]*)"$`, smtpResponseNamedIs)
|
||||
s.Step(`^SMTP client is logged out`, smtpClientIsLoggedOut)
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
func SMTPSetupFeatureContext(s *godog.Suite) {
|
||||
func SMTPSetupFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^there is SMTP client logged in as "([^"]*)"$`, thereIsSMTPClientLoggedInAs)
|
||||
s.Step(`^there is SMTP client "([^"]*)" logged in as "([^"]*)"$`, thereIsSMTPClientNamedLoggedInAs)
|
||||
s.Step(`^there is SMTP client logged in as "([^"]*)" with address "([^"]*)"$`, thereIsSMTPClientLoggedInAsWithAddress)
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func StoreActionsFeatureContext(s *godog.Suite) {
|
||||
func StoreActionsFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^the event loop of "([^"]*)" loops once$`, theEventLoopLoops)
|
||||
s.Step(`^"([^"]*)" receives an address event$`, receivesAnAddressEvent)
|
||||
}
|
||||
|
||||
@ -27,11 +27,11 @@ 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/cucumber/messages-go/v16"
|
||||
"github.com/hashicorp/go-multierror"
|
||||
)
|
||||
|
||||
func StoreChecksFeatureContext(s *godog.Suite) {
|
||||
func StoreChecksFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^"([^"]*)" has mailbox "([^"]*)"$`, userHasMailbox)
|
||||
s.Step(`^"([^"]*)" does not have mailbox "([^"]*)"$`, userDoesNotHaveMailbox)
|
||||
s.Step(`^"([^"]*)" has the following messages$`, userHasFollowingMessages)
|
||||
@ -72,7 +72,7 @@ func userDoesNotHaveMailbox(bddUserID, mailboxName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func userHasFollowingMessages(bddUserID string, structure *gherkin.DataTable) error {
|
||||
func userHasFollowingMessages(bddUserID string, structure *godog.Table) error {
|
||||
return processMailboxStructureDataTable(structure, func(bddAddressID string, mailboxNames string, numberOfMessages int) error {
|
||||
for _, mailboxName := range strings.Split(mailboxNames, ",") {
|
||||
if err := mailboxForAddressOfUserHasNumberOfMessages(mailboxName, bddAddressID, bddUserID, numberOfMessages); err != nil {
|
||||
@ -111,7 +111,7 @@ func mailboxForAddressOfUserHasNumberOfMessages(mailboxName, bddAddressID, bddUs
|
||||
return nil
|
||||
}
|
||||
|
||||
func mailboxForUserHasMessages(mailboxName, bddUserID string, messages *gherkin.DataTable) error {
|
||||
func mailboxForUserHasMessages(mailboxName, bddUserID string, messages *godog.Table) error {
|
||||
return mailboxForAddressOfUserHasMessages(mailboxName, "", bddUserID, messages)
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ func mailboxForUserHasNoMessages(mailboxName, bddUserID string) error {
|
||||
return mailboxForUserHasNumberOfMessages(mailboxName, bddUserID, 0)
|
||||
}
|
||||
|
||||
func mailboxForAddressOfUserHasMessages(mailboxName, bddAddressID, bddUserID string, messages *gherkin.DataTable) error {
|
||||
func mailboxForAddressOfUserHasMessages(mailboxName, bddAddressID, bddUserID string, messages *godog.Table) error {
|
||||
account := ctx.GetTestAccountWithAddress(bddUserID, bddAddressID)
|
||||
if account == nil {
|
||||
return godog.ErrPending
|
||||
@ -172,7 +172,7 @@ func mailboxForAddressOfUserHasMessages(mailboxName, bddAddressID, bddUserID str
|
||||
return nil
|
||||
}
|
||||
|
||||
func pmapiMessagesContainsMessageRow(account *accounts.TestAccount, pmapiMessages []*pmapi.Message, head []*gherkin.TableCell, row *gherkin.TableRow) (bool, error) {
|
||||
func pmapiMessagesContainsMessageRow(account *accounts.TestAccount, pmapiMessages []*pmapi.Message, head []*messages.PickleTableCell, row *messages.PickleTableRow) (bool, error) {
|
||||
messages := make([]interface{}, len(pmapiMessages))
|
||||
for i := range pmapiMessages {
|
||||
messages[i] = pmapiMessages[i]
|
||||
@ -180,7 +180,7 @@ func pmapiMessagesContainsMessageRow(account *accounts.TestAccount, pmapiMessage
|
||||
return messagesContainsMessageRow(account, messages, head, row)
|
||||
}
|
||||
|
||||
func storeMessagesContainsMessageRow(account *accounts.TestAccount, storeMessages []*store.Message, head []*gherkin.TableCell, row *gherkin.TableRow) (bool, error) {
|
||||
func storeMessagesContainsMessageRow(account *accounts.TestAccount, storeMessages []*store.Message, head []*messages.PickleTableCell, row *messages.PickleTableRow) (bool, error) {
|
||||
messages := make([]interface{}, len(storeMessages))
|
||||
for i := range storeMessages {
|
||||
messages[i] = storeMessages[i]
|
||||
@ -188,7 +188,7 @@ func storeMessagesContainsMessageRow(account *accounts.TestAccount, storeMessage
|
||||
return messagesContainsMessageRow(account, messages, head, row)
|
||||
}
|
||||
|
||||
func messagesContainsMessageRow(account *accounts.TestAccount, allMessages []interface{}, head []*gherkin.TableCell, row *gherkin.TableRow) (bool, error) { //nolint[funlen]
|
||||
func messagesContainsMessageRow(account *accounts.TestAccount, allMessages []interface{}, head []*messages.PickleTableCell, row *messages.PickleTableRow) (bool, error) { //nolint[funlen]
|
||||
found := false
|
||||
for _, someMessage := range allMessages {
|
||||
var message *pmapi.Message
|
||||
|
||||
@ -27,10 +27,9 @@ import (
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/pkg/pmapi"
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/gherkin"
|
||||
)
|
||||
|
||||
func StoreSetupFeatureContext(s *godog.Suite) {
|
||||
func StoreSetupFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^there is "([^"]*)" with mailboxes`, thereIsUserWithMailboxes)
|
||||
s.Step(`^there is "([^"]*)" with mailbox "([^"]*)"$`, thereIsUserWithMailbox)
|
||||
s.Step(`^there are messages in mailbox(?:es)? "([^"]*)" for "([^"]*)"$`, thereAreMessagesInMailboxesForUser)
|
||||
@ -40,7 +39,7 @@ func StoreSetupFeatureContext(s *godog.Suite) {
|
||||
s.Step(`^there are (\d+) messages in mailbox(?:es)? "([^"]*)" for address "([^"]*)" of "([^"]*)"$`, thereAreSomeMessagesInMailboxesForAddressOfUser)
|
||||
}
|
||||
|
||||
func thereIsUserWithMailboxes(bddUserID string, mailboxes *gherkin.DataTable) error {
|
||||
func thereIsUserWithMailboxes(bddUserID string, mailboxes *godog.Table) error {
|
||||
for _, row := range mailboxes.Rows {
|
||||
if err := thereIsUserWithMailbox(bddUserID, row.Cells[0].Value); err != nil {
|
||||
return err
|
||||
@ -71,11 +70,11 @@ func thereIsUserWithMailbox(bddUserID, mailboxName string) error {
|
||||
return internalError(store.RebuildMailboxes(), "rebuilding mailboxes")
|
||||
}
|
||||
|
||||
func thereAreMessagesInMailboxesForUser(mailboxNames, bddUserID string, messages *gherkin.DataTable) error {
|
||||
func thereAreMessagesInMailboxesForUser(mailboxNames, bddUserID string, messages *godog.Table) error {
|
||||
return thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, "", bddUserID, messages)
|
||||
}
|
||||
|
||||
func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bddUserID string, messages *gherkin.DataTable) error {
|
||||
func thereAreMessagesInMailboxesForAddressOfUser(mailboxNames, bddAddressID, bddUserID string, messages *godog.Table) error {
|
||||
account := ctx.GetTestAccountWithAddress(bddUserID, bddAddressID)
|
||||
if account == nil {
|
||||
return godog.ErrPending
|
||||
@ -222,13 +221,13 @@ func thereAreSomeMessagesInMailboxesForUser(numberOfMessages int, mailboxNames,
|
||||
return thereAreSomeMessagesInMailboxesForAddressOfUser(numberOfMessages, mailboxNames, "", bddUserID)
|
||||
}
|
||||
|
||||
func thereAreSomeMessagesForUserAsFollows(bddUserID string, structure *gherkin.DataTable) error {
|
||||
func thereAreSomeMessagesForUserAsFollows(bddUserID string, structure *godog.Table) error {
|
||||
return processMailboxStructureDataTable(structure, func(bddAddressID string, mailboxNames string, numberOfMessages int) error {
|
||||
return thereAreSomeMessagesInMailboxesForAddressOfUser(numberOfMessages, mailboxNames, bddAddressID, bddUserID)
|
||||
})
|
||||
}
|
||||
|
||||
func processMailboxStructureDataTable(structure *gherkin.DataTable, callback func(string, string, int) error) error {
|
||||
func processMailboxStructureDataTable(structure *godog.Table, callback func(string, string, int) error) error {
|
||||
head := structure.Rows[0].Cells
|
||||
for i := 1; i < len(structure.Rows); i++ {
|
||||
bddAddressID := ""
|
||||
|
||||
@ -23,10 +23,9 @@ import (
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/internal/transfer"
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/gherkin"
|
||||
)
|
||||
|
||||
func TransferActionsFeatureContext(s *godog.Suite) {
|
||||
func TransferActionsFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^user "([^"]*)" imports local files$`, userImportsLocalFiles)
|
||||
s.Step(`^user "([^"]*)" imports local files with rules$`, userImportsLocalFilesWithRules)
|
||||
s.Step(`^user "([^"]*)" imports local files to address "([^"]*)"$`, userImportsLocalFilesToAddress)
|
||||
@ -51,7 +50,7 @@ func userImportsLocalFiles(bddUserID string) error {
|
||||
return userImportsLocalFilesToAddressWithRules(bddUserID, "", nil)
|
||||
}
|
||||
|
||||
func userImportsLocalFilesWithRules(bddUserID string, rules *gherkin.DataTable) error {
|
||||
func userImportsLocalFilesWithRules(bddUserID string, rules *godog.Table) error {
|
||||
return userImportsLocalFilesToAddressWithRules(bddUserID, "", rules)
|
||||
}
|
||||
|
||||
@ -59,7 +58,7 @@ func userImportsLocalFilesToAddress(bddUserID, bddAddressID string) error {
|
||||
return userImportsLocalFilesToAddressWithRules(bddUserID, bddAddressID, nil)
|
||||
}
|
||||
|
||||
func userImportsLocalFilesToAddressWithRules(bddUserID, bddAddressID string, rules *gherkin.DataTable) error {
|
||||
func userImportsLocalFilesToAddressWithRules(bddUserID, bddAddressID string, rules *godog.Table) error {
|
||||
return doTransfer(bddUserID, bddAddressID, rules, func(username, address string) (*transfer.Transfer, error) {
|
||||
path := ctx.GetTransferLocalRootForImport()
|
||||
return ctx.GetImportExport().GetLocalImporter(username, address, path)
|
||||
@ -72,7 +71,7 @@ func userImportsRemoteMessages(bddUserID string) error {
|
||||
return userImportsRemoteMessagesToAddressWithRules(bddUserID, "", nil)
|
||||
}
|
||||
|
||||
func userImportsRemoteMessagesWithRules(bddUserID string, rules *gherkin.DataTable) error {
|
||||
func userImportsRemoteMessagesWithRules(bddUserID string, rules *godog.Table) error {
|
||||
return userImportsRemoteMessagesToAddressWithRules(bddUserID, "", rules)
|
||||
}
|
||||
|
||||
@ -80,7 +79,7 @@ func userImportsRemoteMessagesToAddress(bddUserID, bddAddressID string) error {
|
||||
return userImportsRemoteMessagesToAddressWithRules(bddUserID, bddAddressID, nil)
|
||||
}
|
||||
|
||||
func userImportsRemoteMessagesToAddressWithRules(bddUserID, bddAddressID string, rules *gherkin.DataTable) error {
|
||||
func userImportsRemoteMessagesToAddressWithRules(bddUserID, bddAddressID string, rules *godog.Table) error {
|
||||
return doTransfer(bddUserID, bddAddressID, rules, func(username, address string) (*transfer.Transfer, error) {
|
||||
imapServer := ctx.GetTransferRemoteIMAPServer()
|
||||
return ctx.GetImportExport().GetRemoteImporter(username, address, imapServer.Username, imapServer.Password, imapServer.Host, imapServer.Port)
|
||||
@ -93,7 +92,7 @@ func userExportsToEMLFiles(bddUserID string) error {
|
||||
return userExportsAddressToEMLFilesWithRules(bddUserID, "", nil)
|
||||
}
|
||||
|
||||
func userExportsToEMLFilesWithRules(bddUserID string, rules *gherkin.DataTable) error {
|
||||
func userExportsToEMLFilesWithRules(bddUserID string, rules *godog.Table) error {
|
||||
return userExportsAddressToEMLFilesWithRules(bddUserID, "", rules)
|
||||
}
|
||||
|
||||
@ -101,7 +100,7 @@ func userExportsAddressToEMLFiles(bddUserID, bddAddressID string) error {
|
||||
return userExportsAddressToEMLFilesWithRules(bddUserID, bddAddressID, nil)
|
||||
}
|
||||
|
||||
func userExportsAddressToEMLFilesWithRules(bddUserID, bddAddressID string, rules *gherkin.DataTable) error {
|
||||
func userExportsAddressToEMLFilesWithRules(bddUserID, bddAddressID string, rules *godog.Table) error {
|
||||
return doTransfer(bddUserID, bddAddressID, rules, func(username, address string) (*transfer.Transfer, error) {
|
||||
path := ctx.GetTransferLocalRootForExport()
|
||||
return ctx.GetImportExport().GetEMLExporter(username, address, path)
|
||||
@ -114,7 +113,7 @@ func userExportsToMBOXFiles(bddUserID string) error {
|
||||
return userExportsAddressToMBOXFilesWithRules(bddUserID, "", nil)
|
||||
}
|
||||
|
||||
func userExportsToMBOXFilesWithRules(bddUserID string, rules *gherkin.DataTable) error {
|
||||
func userExportsToMBOXFilesWithRules(bddUserID string, rules *godog.Table) error {
|
||||
return userExportsAddressToMBOXFilesWithRules(bddUserID, "", rules)
|
||||
}
|
||||
|
||||
@ -122,7 +121,7 @@ func userExportsAddressToMBOXFiles(bddUserID, bddAddressID string) error {
|
||||
return userExportsAddressToMBOXFilesWithRules(bddUserID, bddAddressID, nil)
|
||||
}
|
||||
|
||||
func userExportsAddressToMBOXFilesWithRules(bddUserID, bddAddressID string, rules *gherkin.DataTable) error {
|
||||
func userExportsAddressToMBOXFilesWithRules(bddUserID, bddAddressID string, rules *godog.Table) error {
|
||||
return doTransfer(bddUserID, bddAddressID, rules, func(username, address string) (*transfer.Transfer, error) {
|
||||
path := ctx.GetTransferLocalRootForExport()
|
||||
return ctx.GetImportExport().GetMBOXExporter(username, address, path)
|
||||
@ -131,7 +130,7 @@ func userExportsAddressToMBOXFilesWithRules(bddUserID, bddAddressID string, rule
|
||||
|
||||
// Helpers.
|
||||
|
||||
func doTransfer(bddUserID, bddAddressID string, rules *gherkin.DataTable, getTransferrer func(string, string) (*transfer.Transfer, error)) error {
|
||||
func doTransfer(bddUserID, bddAddressID string, rules *godog.Table, getTransferrer func(string, string) (*transfer.Transfer, error)) error {
|
||||
account := ctx.GetTestAccountWithAddress(bddUserID, bddAddressID)
|
||||
if account == nil {
|
||||
return godog.ErrPending
|
||||
@ -149,7 +148,7 @@ func doTransfer(bddUserID, bddAddressID string, rules *gherkin.DataTable, getTra
|
||||
return nil
|
||||
}
|
||||
|
||||
func setRules(transferrer *transfer.Transfer, rules *gherkin.DataTable) error {
|
||||
func setRules(transferrer *transfer.Transfer, rules *godog.Table) error {
|
||||
if rules == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -29,14 +29,13 @@ import (
|
||||
|
||||
"github.com/ProtonMail/go-rfc5322"
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/gherkin"
|
||||
"github.com/emersion/go-mbox"
|
||||
"github.com/emersion/go-message"
|
||||
"github.com/pkg/errors"
|
||||
a "github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TransferChecksFeatureContext(s *godog.Suite) {
|
||||
func TransferChecksFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^progress result is "([^"]*)"$`, progressFinishedWith)
|
||||
s.Step(`^transfer exported (\d+) messages$`, transferExportedNumberOfMessages)
|
||||
s.Step(`^transfer imported (\d+) messages$`, transferImportedNumberOfMessages)
|
||||
@ -92,7 +91,7 @@ func transferFailedForNumberOfMessages(wantCount int) error {
|
||||
return ctx.GetTestingError()
|
||||
}
|
||||
|
||||
func transferExportedMessages(messages *gherkin.DataTable) error {
|
||||
func transferExportedMessages(messages *godog.Table) error {
|
||||
expectedMessages := map[string][]MessageAttributes{}
|
||||
|
||||
head := messages.Rows[0].Cells
|
||||
|
||||
@ -28,12 +28,12 @@ import (
|
||||
|
||||
"github.com/ProtonMail/proton-bridge/pkg/message"
|
||||
"github.com/cucumber/godog"
|
||||
"github.com/cucumber/godog/gherkin"
|
||||
"github.com/cucumber/messages-go/v16"
|
||||
"github.com/emersion/go-imap"
|
||||
"github.com/emersion/go-mbox"
|
||||
)
|
||||
|
||||
func TransferSetupFeatureContext(s *godog.Suite) {
|
||||
func TransferSetupFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^there are EML files$`, thereAreEMLFiles)
|
||||
s.Step(`^there is EML file "([^"]*)"$`, thereIsEMLFile)
|
||||
s.Step(`^there is MBOX file "([^"]*)" with messages$`, thereIsMBOXFileWithMessages)
|
||||
@ -44,7 +44,7 @@ func TransferSetupFeatureContext(s *godog.Suite) {
|
||||
s.Step(`^there is skip encrypted messages set to "([^"]*)"$`, thereIsSkipEncryptedMessagesSetTo)
|
||||
}
|
||||
|
||||
func thereAreEMLFiles(messages *gherkin.DataTable) error {
|
||||
func thereAreEMLFiles(messages *godog.Table) error {
|
||||
head := messages.Rows[0].Cells
|
||||
for _, row := range messages.Rows[1:] {
|
||||
fileName := ""
|
||||
@ -66,11 +66,11 @@ func thereAreEMLFiles(messages *gherkin.DataTable) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func thereIsEMLFile(fileName string, message *gherkin.DocString) error {
|
||||
func thereIsEMLFile(fileName string, message *godog.DocString) error {
|
||||
return createFile(fileName, message.Content)
|
||||
}
|
||||
|
||||
func thereIsMBOXFileWithMessages(fileName string, messages *gherkin.DataTable) error {
|
||||
func thereIsMBOXFileWithMessages(fileName string, messages *godog.Table) error {
|
||||
mboxBuffer := &bytes.Buffer{}
|
||||
mboxWriter := mbox.NewWriter(mboxBuffer)
|
||||
|
||||
@ -102,11 +102,11 @@ func thereIsMBOXFileWithMessages(fileName string, messages *gherkin.DataTable) e
|
||||
return createFile(fileName, mboxBuffer.String())
|
||||
}
|
||||
|
||||
func thereIsMBOXFile(fileName string, messages *gherkin.DocString) error {
|
||||
func thereIsMBOXFile(fileName string, messages *godog.DocString) error {
|
||||
return createFile(fileName, messages.Content)
|
||||
}
|
||||
|
||||
func thereAreIMAPMailboxes(mailboxes *gherkin.DataTable) error {
|
||||
func thereAreIMAPMailboxes(mailboxes *godog.Table) error {
|
||||
imapServer := ctx.GetTransferRemoteIMAPServer()
|
||||
head := mailboxes.Rows[0].Cells
|
||||
for _, row := range mailboxes.Rows[1:] {
|
||||
@ -124,7 +124,7 @@ func thereAreIMAPMailboxes(mailboxes *gherkin.DataTable) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func thereAreIMAPMessages(messages *gherkin.DataTable) (err error) {
|
||||
func thereAreIMAPMessages(messages *godog.Table) (err error) {
|
||||
imapServer := ctx.GetTransferRemoteIMAPServer()
|
||||
head := messages.Rows[0].Cells
|
||||
for _, row := range messages.Rows[1:] {
|
||||
@ -170,7 +170,7 @@ func thereAreIMAPMessages(messages *gherkin.DataTable) (err error) {
|
||||
return nil
|
||||
}
|
||||
|
||||
func thereIsIMAPMessage(mailboxName string, seqNum, uid int, dateValue, subject string, message *gherkin.DocString) error {
|
||||
func thereIsIMAPMessage(mailboxName string, seqNum, uid int, dateValue, subject string, message *godog.DocString) error {
|
||||
imapServer := ctx.GetTransferRemoteIMAPServer()
|
||||
|
||||
date, err := time.Parse(timeFormat, dateValue)
|
||||
@ -187,7 +187,7 @@ func thereIsIMAPMessage(mailboxName string, seqNum, uid int, dateValue, subject
|
||||
return nil
|
||||
}
|
||||
|
||||
func getBodyFromDataRow(head []*gherkin.TableCell, row *gherkin.TableRow) string {
|
||||
func getBodyFromDataRow(head []*messages.PickleTableCell, row *messages.PickleTableRow) string {
|
||||
body := "hello"
|
||||
headers := textproto.MIMEHeader{}
|
||||
headers.Set("Received", "by 2002:0:0:0:0:0:0:0 with SMTP id 0123456789abcdef; Wed, 30 Dec 2020 01:23:45 0000")
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"github.com/cucumber/godog"
|
||||
)
|
||||
|
||||
func UsersActionsFeatureContext(s *godog.Suite) {
|
||||
func UsersActionsFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^"([^"]*)" logs in$`, userLogsIn)
|
||||
s.Step(`^"([^"]*)" logs in with bad password$`, userLogsInWithBadPassword)
|
||||
s.Step(`^"([^"]*)" logs out$`, userLogsOut)
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
a "github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func UsersChecksFeatureContext(s *godog.Suite) {
|
||||
func UsersChecksFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^"([^"]*)" has address mode in "([^"]*)" mode$`, userHasAddressModeInMode)
|
||||
s.Step(`^"([^"]*)" is disconnected$`, userIsDisconnected)
|
||||
s.Step(`^"([^"]*)" is connected$`, userIsConnected)
|
||||
|
||||
@ -25,7 +25,7 @@ import (
|
||||
a "github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func UsersSetupFeatureContext(s *godog.Suite) {
|
||||
func UsersSetupFeatureContext(s *godog.ScenarioContext) {
|
||||
s.Step(`^there is user "([^"]*)"$`, thereIsUser)
|
||||
s.Step(`^there is connected user "([^"]*)"$`, thereIsConnectedUser)
|
||||
s.Step(`^there is user "([^"]*)" which just logged in$`, thereIsUserWhichJustLoggedIn)
|
||||
|
||||
Reference in New Issue
Block a user