github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/features/bootstrap/context_misc.go (about)

     1  package bootstrap
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/cucumber/godog"
     7  )
     8  
     9  const durationAWhile = time.Second
    10  
    11  // RegisterMiscContext registers godog suite context for handling misc steps
    12  func RegisterMiscContext(ctx *godog.ScenarioContext) {
    13  	scenarioCtx := &miscContext{}
    14  
    15  	ctx.Step(`^I wait for a while$`, scenarioCtx.iWaitForAWhile)
    16  	ctx.Step(`^I wait for "([^"]*)"$`, scenarioCtx.iWaitFor)
    17  }
    18  
    19  type miscContext struct{}
    20  
    21  func (c *miscContext) iWaitForAWhile() error {
    22  	time.Sleep(durationAWhile)
    23  	return nil
    24  }
    25  
    26  func (c *miscContext) iWaitFor(duration string) error {
    27  	parsedDuration, err := time.ParseDuration(duration)
    28  	if nil != err {
    29  		return err
    30  	}
    31  	time.Sleep(parsedDuration)
    32  	return nil
    33  }