-
Notifications
You must be signed in to change notification settings - Fork 961
Expand file tree
/
Copy pathresource_github_actions_organization_secret_migration_test.go
More file actions
74 lines (69 loc) · 1.97 KB
/
resource_github_actions_organization_secret_migration_test.go
File metadata and controls
74 lines (69 loc) · 1.97 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package github
import (
"reflect"
"testing"
)
func Test_resourceGithubActionsOrganizationSecretStateUpgradeV0(t *testing.T) {
t.Parallel()
for _, d := range []struct {
testName string
rawState map[string]any
want map[string]any
shouldError bool
}{
{
testName: "migrates_v0_to_v1",
rawState: map[string]any{
"id": "test-secret",
"secret_name": "test-secret",
"visibility": "private",
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z",
"plaintext_value": "secret-value",
},
want: map[string]any{
"id": "test-secret",
"secret_name": "test-secret",
"visibility": "private",
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z",
"plaintext_value": "secret-value",
"destroy_on_drift": true,
},
shouldError: false,
},
{
testName: "migrates_v0_to_v1_with_existing_destroy_on_drift",
rawState: map[string]any{
"id": "test-secret",
"secret_name": "test-secret",
"visibility": "private",
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z",
"plaintext_value": "secret-value",
"destroy_on_drift": false,
},
want: map[string]any{
"id": "test-secret",
"secret_name": "test-secret",
"visibility": "private",
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z",
"plaintext_value": "secret-value",
"destroy_on_drift": false,
},
shouldError: false,
},
} {
t.Run(d.testName, func(t *testing.T) {
t.Parallel()
got, err := resourceGithubActionsOrganizationSecretStateUpgradeV0(t.Context(), d.rawState, nil)
if (err != nil) != d.shouldError {
t.Fatalf("unexpected error state")
}
if !d.shouldError && !reflect.DeepEqual(got, d.want) {
t.Fatalf("got %+v, want %+v", got, d.want)
}
})
}
}