test added and removed

This commit is contained in:
Drew Bailey 2020-04-06 11:53:46 -04:00
parent 0d550049e9
commit 3b8afce9e6
No known key found for this signature in database
GPG Key ID: FBA61B9FB7CCE1A7
2 changed files with 38 additions and 2 deletions

View File

@ -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)
}

View File

@ -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 {