From 882750c75130de2058e47de51c8d9386d2359343 Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Tue, 22 Jan 2019 10:49:35 -0800 Subject: [PATCH] fix(task): populate created task response, the same as finding The response from a created task was missing the name field; now a test ensures that response matches what is returned when listing tasks. --- task/platform_adapter.go | 11 +++++++++-- task/servicetest/servicetest.go | 4 +++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/task/platform_adapter.go b/task/platform_adapter.go index 540ea74d7e..cab6467be6 100644 --- a/task/platform_adapter.go +++ b/task/platform_adapter.go @@ -75,7 +75,7 @@ func (p pAdapter) CreateTask(ctx context.Context, t *platform.Task) error { return err } - // TODO(mr): decide whether we allow user to configure scheduleAfter. https://github.com/influxdata/influxdb/issues/595 + // TODO(mr): decide whether we allow user to configure scheduleAfter. https://github.com/influxdata/influxdb/issues/10884 scheduleAfter := time.Now().Unix() if t.Status == "" { @@ -95,8 +95,15 @@ func (p pAdapter) CreateTask(ctx context.Context, t *platform.Task) error { return err } t.ID = id - t.Every = opts.Every.String() t.Cron = opts.Cron + t.Name = opts.Name + + if opts.Every != 0 { + t.Every = opts.Every.String() + } + if opts.Offset != 0 { + t.Offset = opts.Offset.String() + } return nil } diff --git a/task/servicetest/servicetest.go b/task/servicetest/servicetest.go index 1e7dcef00e..82112645cc 100644 --- a/task/servicetest/servicetest.go +++ b/task/servicetest/servicetest.go @@ -122,7 +122,9 @@ func testTaskCRUD(t *testing.T, sys *System) { // Look up a task the different ways we can. // Map of method name to found task. - found := make(map[string]*platform.Task) + found := map[string]*platform.Task{ + "Created": task, + } // Find by ID should return the right task. f, err := sys.ts.FindTaskByID(sys.Ctx, task.ID)