forked from hashicorp/terraform-provider-google
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompute_instance_helpers_test.go
41 lines (39 loc) · 1.17 KB
/
compute_instance_helpers_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package compute
import (
"testing"
)
func TestHasTerminationTimeChanged(t *testing.T) {
t.Parallel()
cases := map[string]struct {
Old, New map[string]interface{}
Expect bool
}{
"empty": {
Old: map[string]interface{}{"termination_time": ""},
New: map[string]interface{}{"termination_time": ""},
Expect: false,
},
"new": {
Old: map[string]interface{}{"termination_time": ""},
New: map[string]interface{}{"termination_time": "2025-01-31T15:04:05Z"},
Expect: true,
},
"changed": {
Old: map[string]interface{}{"termination_time": "2025-01-30T15:04:05Z"},
New: map[string]interface{}{"termination_time": "2025-01-31T15:04:05Z"},
Expect: true,
},
"same": {
Old: map[string]interface{}{"termination_time": "2025-01-30T15:04:05Z"},
New: map[string]interface{}{"termination_time": "2025-01-30T15:04:05Z"},
Expect: false,
},
}
for tn, tc := range cases {
if hasTerminationTimeChanged(tc.Old, tc.New) != tc.Expect {
t.Errorf("%s: expected %t for whether termination time matched for old = %q, new = %q", tn, tc.Expect, tc.Old, tc.New)
}
}
}