Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit14598df

Browse files
committed
RED: expand testing with unrelated coder_parameter
1 parent7eff859 commit14598df

File tree

2 files changed

+75
-32
lines changed

2 files changed

+75
-32
lines changed

‎coderd/templateversions_test.go‎

Lines changed: 74 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
293293
type = string
294294
default = "2"
295295
}
296+
data "coder_parameter" "unrelated" {
297+
name = "unrelated"
298+
type = "string"
299+
default = join("", ["a", "b"])
300+
}
296301
resource "null_resource" "test" {}`,
297302
},
298303
wantTags:map[string]string{"owner":"","scope":"organization"},
@@ -301,18 +306,23 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
301306
name:"main.tf with empty workspace tags",
302307
files:map[string]string{
303308
`main.tf`:`
304-
variable "a" {
305-
type = string
306-
default = "1"
307-
}
308-
data "coder_parameter" "b" {
309-
type = string
310-
default = "2"
311-
}
312-
resource "null_resource" "test" {}
313-
data "coder_workspace_tags" "tags" {
314-
tags = {}
315-
}`,
309+
variable "a" {
310+
type = string
311+
default = "1"
312+
}
313+
data "coder_parameter" "b" {
314+
type = string
315+
default = "2"
316+
}
317+
data "coder_parameter" "unrelated" {
318+
name = "unrelated"
319+
type = "string"
320+
default = join("", ["a", "b"])
321+
}
322+
resource "null_resource" "test" {}
323+
data "coder_workspace_tags" "tags" {
324+
tags = {}
325+
}`,
316326
},
317327
wantTags:map[string]string{"owner":"","scope":"organization"},
318328
},
@@ -328,6 +338,11 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
328338
type = string
329339
default = "2"
330340
}
341+
data "coder_parameter" "unrelated" {
342+
name = "unrelated"
343+
type = "string"
344+
default = join("", ["a", "b"])
345+
}
331346
resource "null_resource" "test" {}
332347
data "coder_workspace_tags" "tags" {
333348
tags = {
@@ -343,22 +358,27 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
343358
name:"main.tf with workspace tags and request tags",
344359
files:map[string]string{
345360
`main.tf`:`
346-
variable "a" {
347-
type = string
348-
default = "1"
349-
}
350-
data "coder_parameter" "b" {
351-
type = string
352-
default = "2"
353-
}
354-
resource "null_resource" "test" {}
355-
data "coder_workspace_tags" "tags" {
356-
tags = {
357-
"foo": "bar",
358-
"a": var.a,
359-
"b": data.coder_parameter.b.value,
361+
variable "a" {
362+
type = string
363+
default = "1"
360364
}
361-
}`,
365+
data "coder_parameter" "b" {
366+
type = string
367+
default = "2"
368+
}
369+
data "coder_parameter" "unrelated" {
370+
name = "unrelated"
371+
type = "string"
372+
default = join("", ["a", "b"])
373+
}
374+
resource "null_resource" "test" {}
375+
data "coder_workspace_tags" "tags" {
376+
tags = {
377+
"foo": "bar",
378+
"a": var.a,
379+
"b": data.coder_parameter.b.value,
380+
}
381+
}`,
362382
},
363383
reqTags:map[string]string{"baz":"zap","foo":"noclobber"},
364384
wantTags:map[string]string{"owner":"","scope":"organization","foo":"bar","baz":"zap","a":"1","b":"2"},
@@ -375,6 +395,11 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
375395
type = string
376396
default = "2"
377397
}
398+
data "coder_parameter" "unrelated" {
399+
name = "unrelated"
400+
type = "string"
401+
default = join("", ["a", "b"])
402+
}
378403
resource "null_resource" "test" {
379404
name = "foo"
380405
}
@@ -401,6 +426,11 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
401426
type = string
402427
default = "2"
403428
}
429+
data "coder_parameter" "unrelated" {
430+
name = "unrelated"
431+
type = "string"
432+
default = join("", ["a", "b"])
433+
}
404434
resource "null_resource" "test" {
405435
name = "foo"
406436
}
@@ -423,6 +453,11 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
423453
name:"main.tf with workspace tags that attempts to set user scope",
424454
files:map[string]string{
425455
`main.tf`:`
456+
data "coder_parameter" "unrelated" {
457+
name = "unrelated"
458+
type = "string"
459+
default = join("", ["a", "b"])
460+
}
426461
resource "null_resource" "test" {}
427462
data "coder_workspace_tags" "tags" {
428463
tags = {
@@ -437,6 +472,11 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
437472
name:"main.tf with workspace tags that attempt to clobber org ID",
438473
files:map[string]string{
439474
`main.tf`:`
475+
data "coder_parameter" "unrelated" {
476+
name = "unrelated"
477+
type = "string"
478+
default = join("", ["a", "b"])
479+
}
440480
resource "null_resource" "test" {}
441481
data "coder_workspace_tags" "tags" {
442482
tags = {
@@ -451,6 +491,11 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
451491
name:"main.tf with workspace tags that set scope=user",
452492
files:map[string]string{
453493
`main.tf`:`
494+
data "coder_parameter" "unrelated" {
495+
name = "unrelated"
496+
type = "string"
497+
default = join("", ["a", "b"])
498+
}
454499
resource "null_resource" "test" {}
455500
data "coder_workspace_tags" "tags" {
456501
tags = {
@@ -465,11 +510,10 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
465510
name:"main.tf with no workspace_tags and a function call in a parameter default",
466511
files:map[string]string{
467512
`main.tf`:`
468-
data "coder_parameter" "foo" {
469-
name = "foo"
513+
data "coder_parameter" "unrelated" {
514+
name = "unrelated"
470515
type = "list(string)"
471516
default = jsonencode(["1", "2", "3", "4"])
472-
mutable = true
473517
}`,
474518
},
475519
wantTags:map[string]string{"owner":"","scope":"organization"},

‎provisioner/terraform/tfparse/tfparse.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ func (p *Parser) WorkspaceTagDefaults(ctx context.Context) (map[string]string, e
167167
}
168168

169169
iflen(tags)==0 {
170-
//nolint: nilnil
171-
returnnil,nil
170+
returnmap[string]string{},nil
172171
}
173172

174173
// To evaluate the expressions, we need to load the default values for

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp