Skip to content

Commit 0e710c7

Browse files
committed
more unit tests
1 parent 6b455ce commit 0e710c7

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

provisioner/terraform/parse_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,56 @@ func TestParse(t *testing.T) {
325325
},
326326
},
327327
},
328+
{
329+
Name: "workspace-tags-duplicate-tag",
330+
Files: map[string]string{
331+
"main.tf": `
332+
333+
data "coder_workspace_tags" "custom_workspace_tags" {
334+
tags = {
335+
"cluster" = "developers"
336+
"debug" = "yes"
337+
"debug" = "no"
338+
"cache" = "no-cache"
339+
}
340+
}
341+
`,
342+
},
343+
ErrorContains: `workspace tag "debug" is defined multiple times`,
344+
},
345+
{
346+
Name: "workspace-tags-wrong-tag-format",
347+
Files: map[string]string{
348+
"main.tf": `
349+
350+
data "coder_workspace_tags" "custom_workspace_tags" {
351+
tags {
352+
cluster = "developers"
353+
debug = "yes"
354+
cache = "no-cache"
355+
}
356+
}
357+
`,
358+
},
359+
ErrorContains: `"tags" attribute is required by coder_workspace_tags`,
360+
},
361+
{
362+
Name: "empty-main",
363+
Files: map[string]string{
364+
"main.tf": ``,
365+
},
366+
Response: &proto.ParseComplete{},
367+
},
368+
{
369+
Name: "non-tf-files",
370+
Files: map[string]string{
371+
"readme.md": `Hello world`,
372+
"any-file.txt": "Foobar",
373+
},
374+
Response: &proto.ParseComplete{
375+
Readme: []byte("Hello world"),
376+
},
377+
},
328378
}
329379

330380
for _, testCase := range testCases {

0 commit comments

Comments
 (0)