test(context): Introduce an explicit value merging test
Introduces a test which will merge variables defined at every possible
layer together and ensure that the loaded context configuration is as
expected.
The test data provides an actual resource set template that can be
tested locally from a kontemplate source checkout:
kontemplate template context/testdata/merging/context.yaml --var cliVar=cliVar
This commit is contained in:
parent
4a6f087fbf
commit
6d8214bfc8
5 changed files with 51 additions and 0 deletions
15
context/testdata/merging/context.yaml
vendored
Normal file
15
context/testdata/merging/context.yaml
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
# This context file is intended to test the merge hierarchy of
|
||||
# variables defined at different levels.
|
||||
---
|
||||
context: merging.in.kontemplate.works
|
||||
global:
|
||||
globalVar: globalVar
|
||||
includeVar: should be overridden (global)
|
||||
cliVar: should be overridden (global)
|
||||
import:
|
||||
- import-vars.yaml
|
||||
include:
|
||||
- name: resource
|
||||
values:
|
||||
includeVar: includeVar
|
||||
cliVar: should be overridden (include)
|
||||
4
context/testdata/merging/import-vars.yaml
vendored
Normal file
4
context/testdata/merging/import-vars.yaml
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
importVar: importVar
|
||||
globalVar: should be overridden (import)
|
||||
includeVar: should be overridden (import)
|
||||
cliVar: should be overridden (import)
|
||||
5
context/testdata/merging/resource/default.yaml
vendored
Normal file
5
context/testdata/merging/resource/default.yaml
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
defaultVar: defaultVar
|
||||
importVar: should be overridden (default)
|
||||
globalVar: should be overridden (default)
|
||||
includeVar: should be overridden (default)
|
||||
cliVar: should be overridden (default)
|
||||
5
context/testdata/merging/resource/output.yaml
vendored
Normal file
5
context/testdata/merging/resource/output.yaml
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
defaultVar: {{ .defaultVar }}
|
||||
importVar: {{ .importVar }}
|
||||
globalVar: {{ .globalVar }}
|
||||
includeVar: {{ .includeVar }}
|
||||
cliVar: {{ .cliVar }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue