From 3b8afce9e6fc7b044892a4df27e69c3768af5e8a Mon Sep 17 00:00:00 2001 From: Drew Bailey <2614075+drewbailey@users.noreply.github.com> Date: Mon, 6 Apr 2020 11:53:46 -0400 Subject: [PATCH] test added and removed --- nomad/structs/diff.go | 4 ++-- nomad/structs/diff_test.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/nomad/structs/diff.go b/nomad/structs/diff.go index 251ceee5d..812a28e17 100644 --- a/nomad/structs/diff.go +++ b/nomad/structs/diff.go @@ -226,12 +226,12 @@ func (tg *TaskGroup) Diff(other *TaskGroup, contextual bool) (*TaskGroupDiff, er // ShutdownDelay diff if tg.ShutdownDelay == nil { - oldPrimitiveFlat["ShutdownDelay"] = "nil" + oldPrimitiveFlat["ShutdownDelay"] = "" } else { oldPrimitiveFlat["ShutdownDelay"] = fmt.Sprintf("%d", *tg.ShutdownDelay) } if other.ShutdownDelay == nil { - newPrimitiveFlat["ShutdownDelay"] = "nil" + newPrimitiveFlat["ShutdownDelay"] = "" } else { newPrimitiveFlat["ShutdownDelay"] = fmt.Sprintf("%d", *other.ShutdownDelay) } diff --git a/nomad/structs/diff_test.go b/nomad/structs/diff_test.go index 06ac79ad1..ed6ea0797 100644 --- a/nomad/structs/diff_test.go +++ b/nomad/structs/diff_test.go @@ -3050,6 +3050,42 @@ func TestTaskGroupDiff(t *testing.T) { }, }, }, + { + TestCase: "TaskGroup shutdown_delay removed", + Old: &TaskGroup{ + ShutdownDelay: helper.TimeToPtr(30 * time.Second), + }, + New: &TaskGroup{}, + Expected: &TaskGroupDiff{ + Type: DiffTypeEdited, + Fields: []*FieldDiff{ + { + Type: DiffTypeDeleted, + Name: "ShutdownDelay", + Old: "30000000000", + New: "", + }, + }, + }, + }, + { + TestCase: "TaskGroup shutdown_delay added", + Old: &TaskGroup{}, + New: &TaskGroup{ + ShutdownDelay: helper.TimeToPtr(30 * time.Second), + }, + Expected: &TaskGroupDiff{ + Type: DiffTypeEdited, + Fields: []*FieldDiff{ + { + Type: DiffTypeAdded, + Name: "ShutdownDelay", + Old: "", + New: "30000000000", + }, + }, + }, + }, } for i, c := range cases {