@@ -8,40 +8,33 @@ import (
8
8
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
9
9
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
10
10
"github.com/stretchr/testify/require"
11
-
12
11
"github.com/coder/terraform-provider-coder/provider"
13
12
)
14
13
15
- type ResourceTestData struct {
16
- Name string
17
- ResourceType string
18
- }
19
-
20
14
func TestExamples (t * testing.T ) {
21
15
t .Parallel ()
22
16
23
- for _ , resourceTestData := range []ResourceTestData {
24
- {"coder_parameter" , "data-source" },
25
- {"coder_workspace_tags" , "data-source" },
26
- {"coder_app" , "resource" }
17
+ for _ , testDir := range []string {
18
+ "coder_parameter" ,
19
+ "coder_workspace_tags" ,
27
20
} {
28
- t .Run (resourceTestData . Name , func (t * testing.T ) {
29
- resourceTestData := resourceTestData
21
+ t .Run (testDir , func (t * testing.T ) {
22
+ testDir := testDir
30
23
t .Parallel ()
31
24
32
- resourceTest (t , resourceTestData )
25
+ resourceTest (t , testDir )
33
26
})
34
27
}
35
28
}
36
29
37
- func resourceTest (t * testing.T , testData ResourceTestData ) {
30
+ func resourceTest (t * testing.T , testDir string ) {
38
31
resource .Test (t , resource.TestCase {
39
32
Providers : map [string ]* schema.Provider {
40
33
"coder" : provider .New (),
41
34
},
42
35
IsUnitTest : true ,
43
36
Steps : []resource.TestStep {{
44
- Config : mustReadFile (t , fmt .Sprintf ("../examples/%ss /%s/%s .tf" , testData . ResourceType , testData . Name , testData . ResourceType )),
37
+ Config : mustReadFile (t , fmt .Sprintf ("../examples/data-sources /%s/data-source .tf" , testDir )),
45
38
}},
46
39
})
47
40
}
0 commit comments