-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathexamples_test.go
42 lines (35 loc) · 905 Bytes
/
examples_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package provider_test
import (
"os"
"testing"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/stretchr/testify/require"
"github.com/coder/terraform-provider-coder/provider"
)
func TestExamples(t *testing.T) {
t.Parallel()
for _, testDir := range []string{
"coder_parameter",
"coder_workspace_tags",
} {
t.Run(testDir, func(t *testing.T) {
testDir := testDir
t.Parallel()
resource.Test(t, resource.TestCase{
Providers: map[string]*schema.Provider{
"coder": provider.New(),
},
IsUnitTest: true,
Steps: []resource.TestStep{{
Config: mustReadFile(t, "../examples/resources/"+testDir+"/resource.tf"),
}},
})
})
}
}
func mustReadFile(t *testing.T, path string) string {
content, err := os.ReadFile(path)
require.NoError(t, err)
return string(content)
}