Skip to content

Commit 6849c9d

Browse files
committed
took a stab at expanding example test
1 parent 7638274 commit 6849c9d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

provider/examples_test.go

+14-8
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,36 @@ import (
1212
"github.com/coder/terraform-provider-coder/provider"
1313
)
1414

15+
type ResourceTestData struct {
16+
Name string
17+
ResourceType string
18+
}
19+
1520
func TestExamples(t *testing.T) {
1621
t.Parallel()
1722

18-
for _, testDir := range []string{
19-
"coder_parameter",
20-
"coder_workspace_tags",
23+
for _, resourceTestData := range []ResourceTestData{
24+
{"coder_parameter", "data-source"},
25+
{"coder_workspace_tags", "data-source"},
26+
{"coder_app", "resource"}
2127
} {
22-
t.Run(testDir, func(t *testing.T) {
23-
testDir := testDir
28+
t.Run(resourceTestData.Name, func(t *testing.T) {
29+
resourceTestData := resourceTestData
2430
t.Parallel()
2531

26-
resourceTest(t, testDir)
32+
resourceTest(t, resourceTestData)
2733
})
2834
}
2935
}
3036

31-
func resourceTest(t *testing.T, testDir string) {
37+
func resourceTest(t *testing.T, testData ResourceTestData) {
3238
resource.Test(t, resource.TestCase{
3339
Providers: map[string]*schema.Provider{
3440
"coder": provider.New(),
3541
},
3642
IsUnitTest: true,
3743
Steps: []resource.TestStep{{
38-
Config: mustReadFile(t, fmt.Sprintf("../examples/data-sources/%s/data-source.tf", testDir)),
44+
Config: mustReadFile(t, fmt.Sprintf("../examples/%ss/%s/%s.tf", testData.ResourceType, testData.Name, testData.ResourceType)),
3945
}},
4046
})
4147
}

0 commit comments

Comments
 (0)