Skip to content

Commit ccb76a4

Browse files
committed
fixup tag tests
1 parent 83e643d commit ccb76a4

File tree

1 file changed

+19
-40
lines changed

1 file changed

+19
-40
lines changed

coderd/templateversions_test.go

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
275275
files map[string]string
276276
reqTags map[string]string
277277
wantTags map[string]string
278+
variables []codersdk.VariableValue
278279
expectError string
279280
}{
280281
{
@@ -290,6 +291,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
290291
default = "1"
291292
}
292293
data "coder_parameter" "b" {
294+
name = "b"
293295
type = string
294296
default = "2"
295297
}
@@ -311,6 +313,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
311313
default = "1"
312314
}
313315
data "coder_parameter" "b" {
316+
name = "b"
314317
type = string
315318
default = "2"
316319
}
@@ -335,6 +338,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
335338
default = "1"
336339
}
337340
data "coder_parameter" "b" {
341+
name = "b"
338342
type = string
339343
default = "2"
340344
}
@@ -365,6 +369,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
365369
default = "1"
366370
}
367371
data "coder_parameter" "b" {
372+
name = "b"
368373
type = string
369374
default = "2"
370375
}
@@ -395,6 +400,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
395400
default = "1"
396401
}
397402
data "coder_parameter" "b" {
403+
name = "b"
398404
type = string
399405
default = "2"
400406
}
@@ -429,18 +435,20 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
429435
}
430436
}`,
431437
},
432-
reqTags: map[string]string{"a": "b"},
433-
wantTags: map[string]string{"owner": "", "scope": "organization", "a": "b"},
438+
reqTags: map[string]string{"a": "b"},
439+
wantTags: map[string]string{"owner": "", "scope": "organization", "a": "b"},
440+
variables: []codersdk.VariableValue{{Name: "a", Value: "b"}},
434441
},
435442
{
436-
name: "main.tf with disallowed workspace tag value",
443+
name: "main.tf with resource reference",
437444
files: map[string]string{
438445
`main.tf`: `
439446
variable "a" {
440447
type = string
441448
default = "1"
442449
}
443450
data "coder_parameter" "b" {
451+
name = "b"
444452
type = string
445453
default = "2"
446454
}
@@ -461,38 +469,8 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
461469
}
462470
}`,
463471
},
464-
expectError: `Unknown variable; There is no variable named "null_resource".`,
465-
},
466-
{
467-
name: "main.tf with disallowed function in tag value",
468-
files: map[string]string{
469-
`main.tf`: `
470-
variable "a" {
471-
type = string
472-
default = "1"
473-
}
474-
data "coder_parameter" "b" {
475-
type = string
476-
default = "2"
477-
}
478-
data "coder_parameter" "unrelated" {
479-
name = "unrelated"
480-
type = "list(string)"
481-
default = jsonencode(["a", "b"])
482-
}
483-
resource "null_resource" "test" {
484-
name = "foo"
485-
}
486-
data "coder_workspace_tags" "tags" {
487-
tags = {
488-
"foo": "bar",
489-
"a": var.a,
490-
"b": data.coder_parameter.b.value,
491-
"test": pathexpand("~/file.txt"),
492-
}
493-
}`,
494-
},
495-
expectError: `function "pathexpand" may not be used here`,
472+
reqTags: map[string]string{"foo": "bar", "a": "1", "b": "2", "test": "foo"},
473+
wantTags: map[string]string{"owner": "", "scope": "organization", "foo": "bar", "a": "1", "b": "2", "test": "foo"},
496474
},
497475
// We will allow coder_workspace_tags to set the scope on a template version import job
498476
// BUT the user ID will be ultimately determined by the API key in the scope.
@@ -618,11 +596,12 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
618596
// Create a template version from the archive
619597
tvName := testutil.GetRandomNameHyphenated(t)
620598
tv, err := templateAdmin.CreateTemplateVersion(ctx, owner.OrganizationID, codersdk.CreateTemplateVersionRequest{
621-
Name: tvName,
622-
StorageMethod: codersdk.ProvisionerStorageMethodFile,
623-
Provisioner: codersdk.ProvisionerTypeTerraform,
624-
FileID: fi.ID,
625-
ProvisionerTags: tt.reqTags,
599+
Name: tvName,
600+
StorageMethod: codersdk.ProvisionerStorageMethodFile,
601+
Provisioner: codersdk.ProvisionerTypeTerraform,
602+
FileID: fi.ID,
603+
ProvisionerTags: tt.reqTags,
604+
UserVariableValues: tt.variables,
626605
})
627606

628607
if tt.expectError == "" {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy