@@ -8,68 +8,62 @@ import (
8
8
)
9
9
10
10
func Test_resourceSchema (t * testing.T ) {
11
- cases := []struct {
12
- name string
11
+ cases := map [string ]struct {
13
12
schemas map [string ]* tfjson.Schema
14
13
providerShortName string
15
14
templateFileName string
16
15
expectedSchema * tfjson.Schema
17
16
expectedResourceName string
18
17
}{
19
- {
20
- "provider short name matches schema name" ,
21
- map [string ]* tfjson.Schema {
18
+ "provider short name matches schema name" : {
19
+ schemas : map [string ]* tfjson.Schema {
22
20
"http" : {},
23
21
},
24
- "http" ,
25
- "http.md.tmpl" ,
26
- & tfjson.Schema {},
27
- "http" ,
22
+ providerShortName : "http" ,
23
+ templateFileName : "http.md.tmpl" ,
24
+ expectedSchema : & tfjson.Schema {},
25
+ expectedResourceName : "http" ,
28
26
},
29
- {
30
- "provider short name does not match schema name" ,
31
- map [string ]* tfjson.Schema {
27
+ "provider short name does not match schema name" : {
28
+ schemas : map [string ]* tfjson.Schema {
32
29
"http" : {},
33
30
},
34
- "tls" ,
35
- "http.md.tmpl" ,
36
- nil ,
37
- "" ,
31
+ providerShortName : "tls" ,
32
+ templateFileName : "http.md.tmpl" ,
33
+ expectedSchema : nil ,
34
+ expectedResourceName : "" ,
38
35
},
39
- {
40
- "provider short name concatenated with template file name matches schema name" ,
41
- map [string ]* tfjson.Schema {
36
+ "provider short name concatenated with template file name matches schema name" : {
37
+ schemas : map [string ]* tfjson.Schema {
42
38
"tls_cert_request" : {},
43
39
},
44
- "tls" ,
45
- "cert_request.md.tmpl" ,
46
- & tfjson.Schema {},
47
- "tls_cert_request" ,
40
+ providerShortName : "tls" ,
41
+ templateFileName : "cert_request.md.tmpl" ,
42
+ expectedSchema : & tfjson.Schema {},
43
+ expectedResourceName : "tls_cert_request" ,
48
44
},
49
- {
50
- "provider short name concatenated with template file name does not match schema name" ,
51
- map [string ]* tfjson.Schema {
45
+ "provider short name concatenated with template file name does not match schema name" : {
46
+ schemas : map [string ]* tfjson.Schema {
52
47
"tls_cert_request" : {},
53
48
},
54
- "tls" ,
55
- "not_found.md.tmpl" ,
56
- nil ,
57
- "" ,
49
+ providerShortName : "tls" ,
50
+ templateFileName : "not_found.md.tmpl" ,
51
+ expectedSchema : nil ,
52
+ expectedResourceName : "" ,
58
53
},
59
- {
60
- "provider short name concatenated with same template file name matches schema name" ,
61
- map [string ]* tfjson.Schema {
54
+ "provider short name concatenated with same template file name matches schema name" : {
55
+ schemas : map [string ]* tfjson.Schema {
62
56
"tls_tls" : {},
63
57
},
64
- "tls" ,
65
- "tls.md.tmpl" ,
66
- & tfjson.Schema {},
67
- "tls_tls" ,
58
+ providerShortName : "tls" ,
59
+ templateFileName : "tls.md.tmpl" ,
60
+ expectedSchema : & tfjson.Schema {},
61
+ expectedResourceName : "tls_tls" ,
68
62
},
69
63
}
70
64
71
- for _ , c := range cases {
72
- t .Run (c . name , func (t * testing.T ) {
65
+ for name , c := range cases {
66
+ t .Run (name , func (t * testing.T ) {
73
67
actualSchema , actualResourceName := resourceSchema (c .schemas , c .providerShortName , c .templateFileName )
74
68
75
69
if ! cmp .Equal (c .expectedSchema , actualSchema ) {
0 commit comments