Skip to content

Commit d6cc333

Browse files
committed
Adding field names to test structs
1 parent b0001a4 commit d6cc333

File tree

1 file changed

+33
-39
lines changed

1 file changed

+33
-39
lines changed

internal/provider/util_test.go

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,62 @@ import (
88
)
99

1010
func Test_resourceSchema(t *testing.T) {
11-
cases := []struct {
12-
name string
11+
cases := map[string]struct {
1312
schemas map[string]*tfjson.Schema
1413
providerShortName string
1514
templateFileName string
1615
expectedSchema *tfjson.Schema
1716
expectedResourceName string
1817
}{
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{
2220
"http": {},
2321
},
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",
2826
},
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{
3229
"http": {},
3330
},
34-
"tls",
35-
"http.md.tmpl",
36-
nil,
37-
"",
31+
providerShortName: "tls",
32+
templateFileName: "http.md.tmpl",
33+
expectedSchema: nil,
34+
expectedResourceName: "",
3835
},
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{
4238
"tls_cert_request": {},
4339
},
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",
4844
},
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{
5247
"tls_cert_request": {},
5348
},
54-
"tls",
55-
"not_found.md.tmpl",
56-
nil,
57-
"",
49+
providerShortName: "tls",
50+
templateFileName: "not_found.md.tmpl",
51+
expectedSchema: nil,
52+
expectedResourceName: "",
5853
},
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{
6256
"tls_tls": {},
6357
},
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",
6862
},
6963
}
7064

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) {
7367
actualSchema, actualResourceName := resourceSchema(c.schemas, c.providerShortName, c.templateFileName)
7468

7569
if !cmp.Equal(c.expectedSchema, actualSchema) {

0 commit comments

Comments
 (0)