add runTask test (#131)

This commit is contained in:
Pedro Nasser
2016-10-12 17:32:06 -03:00
committed by C Cirello
parent 2e12e2c700
commit 1ff480561a
2 changed files with 25 additions and 8 deletions

View File

@@ -16,6 +16,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/iron-io/functions/api/models"
"github.com/iron-io/functions/api/mqs"
"github.com/iron-io/runner/drivers"
)
func getMockTask() models.Task {
@@ -79,6 +80,22 @@ func getTestServer(mockTasks []*models.Task) *httptest.Server {
return httptest.NewServer(r)
}
var helloImage = "iron/hello"
func TestRunTask(t *testing.T) {
mockTask := getMockTask()
mockTask.Image = &helloImage
result, err := runTask(&mockTask)
if err != nil {
t.Error(err)
}
if result.Status() != "success" {
t.Errorf("TestRunTask failed to execute runTask")
}
}
func TestGetTask(t *testing.T) {
mockTask := getMockTask()
@@ -178,8 +195,8 @@ func TestAsyncRunnersGracefulShutdown(t *testing.T) {
ctx, _ := context.WithTimeout(context.Background(), 2*time.Second)
var wg sync.WaitGroup
wg.Add(1)
go startAsyncRunners(ctx, &wg, 0, ts.URL+"/tasks", func(task *models.Task) error {
return nil
go startAsyncRunners(ctx, &wg, 0, ts.URL+"/tasks", func(task *models.Task) (drivers.RunResult, error) {
return nil, nil
})
wg.Wait()