forked from hashicorp/terraform-provider-azurerm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthorization_id_test.go
88 lines (73 loc) · 2.08 KB
/
authorization_id_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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package validate
// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten
import "testing"
func TestAuthorizationID(t *testing.T) {
cases := []struct {
Input string
Valid bool
}{
{
// empty
Input: "",
Valid: false,
},
{
// missing SubscriptionId
Input: "/",
Valid: false,
},
{
// missing value for SubscriptionId
Input: "/subscriptions/",
Valid: false,
},
{
// missing ResourceGroup
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/",
Valid: false,
},
{
// missing value for ResourceGroup
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/",
Valid: false,
},
{
// missing PrivateCloudName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.AVS/",
Valid: false,
},
{
// missing value for PrivateCloudName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/",
Valid: false,
},
{
// missing Name
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1/",
Valid: false,
},
{
// missing value for Name
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1/authorizations/",
Valid: false,
},
{
// valid
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/privateCloud1/authorizations/authorization1",
Valid: true,
},
{
// upper-cased
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/GROUP1/PROVIDERS/MICROSOFT.AVS/PRIVATECLOUDS/PRIVATECLOUD1/AUTHORIZATIONS/AUTHORIZATION1",
Valid: false,
},
}
for _, tc := range cases {
t.Logf("[DEBUG] Testing Value %s", tc.Input)
_, errors := AuthorizationID(tc.Input, "test")
valid := len(errors) == 0
if tc.Valid != valid {
t.Fatalf("Expected %t but got %t", tc.Valid, valid)
}
}
}