Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
bcdaf74
chore: refactor provisioner to handle more discrete terraform actions
Emyrk Nov 25, 2025
a148996
chore: initial init work, does not work for template import yet
Emyrk Nov 25, 2025
f9fb825
init step broken out
Emyrk Nov 25, 2025
8176ece
chore: echo provisioner, graph, and init
Emyrk Nov 25, 2025
c89d824
graph step in executor
Emyrk Nov 25, 2025
cbac23e
formatting
Emyrk Nov 25, 2025
94aa0f7
fix echo provisioner
Emyrk Nov 25, 2025
d454ca1
fmt
Emyrk Nov 25, 2025
2ac5bcf
fix dynamic param test
Emyrk Nov 25, 2025
3c94ed9
fix tests
Emyrk Nov 25, 2025
0e00edf
solve more tests
Emyrk Nov 25, 2025
d15327a
solve more tests
Emyrk Nov 25, 2025
121f9f8
more test fixes
Emyrk Nov 26, 2025
974dff9
fmt
Emyrk Nov 26, 2025
3e0c099
test fixes
Emyrk Nov 26, 2025
41f9dd5
test fixes
Emyrk Nov 26, 2025
4373086
make fmt
Emyrk Nov 26, 2025
8ef0f89
provisioner test fixes
Emyrk Nov 26, 2025
346183a
scaletest fixes
Emyrk Nov 26, 2025
c8c6e3d
test fixes
Emyrk Nov 26, 2025
7bf9707
provisioner test fixes
Emyrk Nov 26, 2025
11815cb
make gen
Emyrk Nov 26, 2025
ef7b33e
e2e fixes
Emyrk Nov 26, 2025
a422514
fmt
Emyrk Nov 26, 2025
c79f45e
graph is at the end now
Emyrk Nov 26, 2025
1c76f44
test
Emyrk Nov 26, 2025
de93769
ci push
Emyrk Nov 26, 2025
0a69503
make gen
Emyrk Nov 26, 2025
cf5acd3
more test fixes
Emyrk Nov 26, 2025
b6c2671
more test fixes
Emyrk Nov 26, 2025
54109a4
fix linting
Emyrk Nov 26, 2025
9630d94
fix linting
Emyrk Nov 26, 2025
7ac45f3
timing fixes
Emyrk Nov 26, 2025
3d3b293
linting
Emyrk Nov 26, 2025
25aa046
more tests
Emyrk Nov 26, 2025
9e19ed4
more tests
Emyrk Nov 26, 2025
9e7fb7e
more tests
Emyrk Nov 26, 2025
07c65a9
more tests
Emyrk Nov 26, 2025
b93321e
more tests
Emyrk Dec 1, 2025
9a6ab44
more tests
Emyrk Dec 1, 2025
7494a9b
more tests
Emyrk Dec 1, 2025
07c8383
fix provisioner test
Emyrk Dec 1, 2025
14ee7f2
fix script envs
Emyrk Dec 1, 2025
feb63df
fix script envs
Emyrk Dec 1, 2025
f978207
more fixes to provisioning test
Emyrk Dec 1, 2025
08078c6
flip asserts
Emyrk Dec 1, 2025
bcf9ff6
add logs to timing test
Emyrk Dec 1, 2025
336231e
linting
Emyrk Dec 1, 2025
bee6934
fix race condition
Emyrk Dec 1, 2025
9906c0a
add e2e echos
Emyrk Dec 1, 2025
63fd15f
add e2e echos
Emyrk Dec 1, 2025
3d2c059
e2e changes
Emyrk Dec 1, 2025
32da8c7
init timing arrays
Emyrk Dec 1, 2025
e86c6e2
init timing arrays
Emyrk Dec 1, 2025
99e3fd9
fix serialization
Emyrk Dec 1, 2025
7add31c
revert playwright change
Emyrk Dec 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test fixes
  • Loading branch information
Emyrk committed Dec 2, 2025
commit 41f9dd504b9736e259482f42370f0c995524ac4d
86 changes: 66 additions & 20 deletions provisioner/terraform/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ func TestParse(t *testing.T) {
Name string
Files map[string]string
Response *proto.ParseComplete
// If ErrorContains is not empty, then the ParseComplete should have an Error containing the given string
ErrorContains string
// If ErrorContains is not empty, then the InitComplete should have an Error containing the given string
ErrorContains string
ParseErrorContains string
}{
{
Name: "single-variable",
Expand Down Expand Up @@ -63,6 +64,7 @@ func TestParse(t *testing.T) {
"main.tf": `variable "A" {
validation {
condition = var.A == "value"
error_message = "A must be 'value'"
}
}`,
},
Expand All @@ -80,7 +82,7 @@ func TestParse(t *testing.T) {
Files: map[string]string{
"main.tf": "a;sd;ajsd;lajsd;lasjdf;a",
},
ErrorContains: `The ";" character is not valid.`,
ErrorContains: `initialize terraform: exit status 1`,
},
{
Name: "multiple-variables",
Expand Down Expand Up @@ -205,6 +207,15 @@ func TestParse(t *testing.T) {
{
Name: "workspace-tags",
Files: map[string]string{
`main.tf`: `
terraform {
required_providers {
coder = {
source = "coder/coder"
}
}
}
`,
"parameters.tf": `data "coder_parameter" "os_selector" {
name = "os_selector"
display_name = "Operating System"
Expand Down Expand Up @@ -266,7 +277,13 @@ func TestParse(t *testing.T) {
Name: "workspace-tags-in-a-single-file",
Files: map[string]string{
"main.tf": `

terraform {
required_providers {
coder = {
source = "coder/coder"
}
}
}
data "coder_parameter" "os_selector" {
name = "os_selector"
display_name = "Operating System"
Expand Down Expand Up @@ -330,7 +347,13 @@ func TestParse(t *testing.T) {
Name: "workspace-tags-duplicate-tag",
Files: map[string]string{
"main.tf": `

terraform {
required_providers {
coder = {
source = "coder/coder"
}
}
}
data "coder_workspace_tags" "custom_workspace_tags" {
tags = {
"cluster" = "developers"
Expand All @@ -341,23 +364,30 @@ func TestParse(t *testing.T) {
}
`,
},
ErrorContains: `workspace tag "debug" is defined multiple times`,
ParseErrorContains: `workspace tag "debug" is defined multiple times`,
},
{
Name: "workspace-tags-wrong-tag-format",
Files: map[string]string{
"main.tf": `
terraform {
required_providers {
coder = {
source = "coder/coder"
}
}
}

data "coder_workspace_tags" "custom_workspace_tags" {
tags {
cluster = "developers"
debug = "yes"
cache = "no-cache"
data "coder_workspace_tags" "custom_workspace_tags" {
tags {
cluster = "developers"
debug = "yes"
cache = "no-cache"
}
}
}
`,
},
ErrorContains: `"tags" attribute is required by coder_workspace_tags`,
ParseErrorContains: `"tags" attribute is required by coder_workspace_tags`,
},
{
Name: "empty-main",
Expand All @@ -379,27 +409,43 @@ func TestParse(t *testing.T) {
t.Run(testCase.Name, func(t *testing.T) {
t.Parallel()

session := configure(ctx, t, api, &proto.Config{
TemplateSourceArchive: testutil.CreateTar(t, testCase.Files),
})

err := session.Send(&proto.Request{Type: &proto.Request_Parse{Parse: &proto.ParseRequest{}}})
session := configure(ctx, t, api, &proto.Config{})
err := sendInit(session, testutil.CreateTar(t, testCase.Files))
require.NoError(t, err)

// Init stage
for {
msg, err := session.Recv()
require.NoError(t, err)
if msgLog, ok := msg.Type.(*proto.Response_Log); ok {
t.Logf("init log: %s", msgLog.Log.Output)
continue
}

if testCase.ErrorContains != "" {
require.Contains(t, msg.GetParse().GetError(), testCase.ErrorContains)
break
require.Contains(t, msg.GetInit().GetError(), testCase.ErrorContains)
return // Stop test at this point
}
break
}

err = session.Send(&proto.Request{Type: &proto.Request_Parse{Parse: &proto.ParseRequest{}}})
require.NoError(t, err)

for {
msg, err := session.Recv()
require.NoError(t, err)

// Ignore logs in this test
if msg.GetLog() != nil {
continue
}

if testCase.ParseErrorContains != "" {
require.Contains(t, msg.GetParse().GetError(), testCase.ParseErrorContains)
return // Stop test at this point
}

// Ensure the want and got are equivalent!
want, err := json.Marshal(testCase.Response)
require.NoError(t, err)
Expand Down
Loading