github.com/greenboxal/deis@v1.12.1/builder/commands_test.go (about)

     1  package builder
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/Masterminds/cookoo"
     8  )
     9  
    10  func TestSleep(t *testing.T) {
    11  	reg, router, cxt := cookoo.Cookoo()
    12  
    13  	reg.Route("test", "Test route").
    14  		Does(Sleep, "res").Using("duration").WithDefault(3 * time.Second)
    15  
    16  	start := time.Now()
    17  	if err := router.HandleRequest("test", cxt, true); err != nil {
    18  		t.Error(err)
    19  	}
    20  
    21  	end := time.Now()
    22  	if end.Sub(start) < 3*time.Second {
    23  		t.Error("expected elapsed time to be 3 seconds.")
    24  	}
    25  
    26  }