Skip to content

chore(docs): move coder_parameter example #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 25, 2024
Prev Previous commit
Next Next commit
took a stab at expanding example test
  • Loading branch information
stirby committed Jun 25, 2024
commit 6849c9dd84e5eb5dff9760f85446f88cd3fbd362
22 changes: 14 additions & 8 deletions provider/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,36 @@
"github.com/coder/terraform-provider-coder/provider"
)

type ResourceTestData struct {
Name string
ResourceType string
}

func TestExamples(t *testing.T) {
t.Parallel()

for _, testDir := range []string{
"coder_parameter",
"coder_workspace_tags",
for _, resourceTestData := range []ResourceTestData{
{"coder_parameter", "data-source"},
{"coder_workspace_tags", "data-source"},
{"coder_app", "resource"}

Check failure on line 26 in provider/examples_test.go

View workflow job for this annotation

GitHub Actions / Matrix Test (1.0.*)

missing ',' before newline in composite literal

Check failure on line 26 in provider/examples_test.go

View workflow job for this annotation

GitHub Actions / Matrix Test (1.1.*)

missing ',' before newline in composite literal

Check failure on line 26 in provider/examples_test.go

View workflow job for this annotation

GitHub Actions / Matrix Test (1.2.*)

missing ',' before newline in composite literal

Check failure on line 26 in provider/examples_test.go

View workflow job for this annotation

GitHub Actions / Matrix Test (1.3.*)

missing ',' before newline in composite literal

Check failure on line 26 in provider/examples_test.go

View workflow job for this annotation

GitHub Actions / Matrix Test (1.4.*)

missing ',' before newline in composite literal

Check failure on line 26 in provider/examples_test.go

View workflow job for this annotation

GitHub Actions / Matrix Test (1.5.*)

missing ',' before newline in composite literal

Check failure on line 26 in provider/examples_test.go

View workflow job for this annotation

GitHub Actions / Matrix Test (1.6.*)

missing ',' before newline in composite literal

Check failure on line 26 in provider/examples_test.go

View workflow job for this annotation

GitHub Actions / Matrix Test (1.7.*)

missing ',' before newline in composite literal

Check failure on line 26 in provider/examples_test.go

View workflow job for this annotation

GitHub Actions / Matrix Test (1.8.*)

missing ',' before newline in composite literal
} {
t.Run(testDir, func(t *testing.T) {
testDir := testDir
t.Run(resourceTestData.Name, func(t *testing.T) {
resourceTestData := resourceTestData
t.Parallel()

resourceTest(t, testDir)
resourceTest(t, resourceTestData)
})
}
}

func resourceTest(t *testing.T, testDir string) {
func resourceTest(t *testing.T, testData ResourceTestData) {
resource.Test(t, resource.TestCase{
Providers: map[string]*schema.Provider{
"coder": provider.New(),
},
IsUnitTest: true,
Steps: []resource.TestStep{{
Config: mustReadFile(t, fmt.Sprintf("../examples/data-sources/%s/data-source.tf", testDir)),
Config: mustReadFile(t, fmt.Sprintf("../examples/%ss/%s/%s.tf", testData.ResourceType, testData.Name, testData.ResourceType)),
}},
})
}
Expand Down
Loading