test: add test with changing address order

This commit is contained in:
James Houlahan
2020-05-06 09:57:34 +02:00
parent c61e8bdc71
commit 2d200f6f8c
19 changed files with 202 additions and 23 deletions

View File

@ -18,11 +18,15 @@
package tests
import (
"time"
"github.com/cucumber/godog"
"github.com/stretchr/testify/assert"
)
func StoreActionsFeatureContext(s *godog.Suite) {
s.Step(`^the event loop of "([^"]*)" loops once$`, theEventLoopLoops)
s.Step(`^"([^"]*)" receives an address event$`, receivesAnAddressEvent)
}
func theEventLoopLoops(username string) error {
@ -37,3 +41,19 @@ func theEventLoopLoops(username string) error {
store.TestPollNow()
return nil
}
func receivesAnAddressEvent(username string) error {
acc := ctx.GetTestAccount(username)
if acc == nil {
return godog.ErrPending
}
store, err := ctx.GetStore(acc.Username())
if err != nil {
return internalError(err, "getting store of user %s", username)
}
assert.Eventually(ctx.GetTestingT(), func() bool {
store.TestPollNow()
return len(store.TestGetLastEvent().Addresses) > 0
}, 5*time.Second, time.Second)
return nil
}