Skip to content

Commit f6b2c1a

Browse files
committed
add yq tests for nested path and helmfile
1 parent ed89ec7 commit f6b2c1a

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

pkg/list/list_values_test.go

+46
Original file line numberDiff line numberDiff line change
@@ -409,3 +409,49 @@ func TestFilterAndListValues(t *testing.T) {
409409
})
410410
}
411411
}
412+
413+
func TestBuildComponentYqExpression(t *testing.T) {
414+
tests := []struct {
415+
name string
416+
component string
417+
includeAbstract bool
418+
componentType string
419+
expected string
420+
}{
421+
{
422+
name: "basic component without including abstract",
423+
component: "vpc",
424+
includeAbstract: false,
425+
componentType: "terraform",
426+
expected: ".components.terraform.\"vpc\" | select(has(\"abstract\") == false or .abstract == false) | .vars",
427+
},
428+
{
429+
name: "basic component including abstract",
430+
component: "vpc",
431+
includeAbstract: true,
432+
componentType: "terraform",
433+
expected: ".components.terraform.\"vpc\" | .vars",
434+
},
435+
{
436+
name: "nested component without including abstract",
437+
component: "nested/vpc",
438+
includeAbstract: false,
439+
componentType: "terraform",
440+
expected: ".components.terraform.\"nested/vpc\" | select(has(\"abstract\") == false or .abstract == false) | .vars",
441+
},
442+
{
443+
name: "helmfile component",
444+
component: "nginx",
445+
includeAbstract: false,
446+
componentType: "helmfile",
447+
expected: ".components.helmfile.\"nginx\" | select(has(\"abstract\") == false or .abstract == false) | .vars",
448+
},
449+
}
450+
451+
for _, tt := range tests {
452+
t.Run(tt.name, func(t *testing.T) {
453+
result := buildComponentYqExpression(tt.component, tt.includeAbstract, tt.componentType)
454+
assert.Equal(t, tt.expected, result)
455+
})
456+
}
457+
}

0 commit comments

Comments
 (0)