MCPcopy Index your code
hub / github.com/coder/coder / TestParse

Function TestParse

provisioner/terraform/parse_test.go:17–432  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestParse(t *testing.T) {
18 t.Parallel()
19
20 cwd, err := os.Getwd()
21 require.NoError(t, err)
22
23 ctx, api := setupProvisioner(t, &provisionerServeOptions{
24 // Fake all actual terraform, since parse doesn't need it.
25 binaryPath: filepath.Join(cwd, "testdata", "timings-aggregation", "fake-terraform.sh"),
26 })
27
28 testCases := []struct {
29 Name string
30 Files map[string]string
31 Response *proto.ParseComplete
32 ParseErrorContains string
33 }{
34 {
35 Name: "single-variable",
36 Files: map[string]string{
37 "main.tf": `variable "A" {
38 description = "Testing!"
39 }`,
40 },
41 Response: &proto.ParseComplete{
42 TemplateVariables: []*proto.TemplateVariable{
43 {
44 Name: "A",
45 Description: "Testing!",
46 Required: true,
47 },
48 },
49 },
50 },
51 {
52 Name: "default-variable-value",
53 Files: map[string]string{
54 "main.tf": `variable "A" {
55 default = "wow"
56 }`,
57 },
58 Response: &proto.ParseComplete{
59 TemplateVariables: []*proto.TemplateVariable{
60 {
61 Name: "A",
62 DefaultValue: "wow",
63 },
64 },
65 },
66 },
67 {
68 Name: "variable-validation",
69 Files: map[string]string{
70 "main.tf": `variable "A" {
71 validation {
72 condition = var.A == "value"
73 error_message = "A must be 'value'"
74 }

Callers

nothing calls this directly

Calls 14

CreateTarFunction · 0.92
setupProvisionerFunction · 0.85
configureFunction · 0.85
sendInitFunction · 0.85
RunMethod · 0.65
RecvMethod · 0.65
LogfMethod · 0.65
SendMethod · 0.65
GetLogMethod · 0.45
ContainsMethod · 0.45
GetErrorMethod · 0.45
GetParseMethod · 0.45

Tested by

no test coverage detected