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:
Vincent Ambo 2018-06-26 12:25:55 +02:00 committed by Vincent Ambo
parent 4a6f087fbf
commit 6d8214bfc8
5 changed files with 51 additions and 0 deletions

15
context/testdata/merging/context.yaml vendored Normal file
View 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)

View file

@ -0,0 +1,4 @@
importVar: importVar
globalVar: should be overridden (import)
includeVar: should be overridden (import)
cliVar: should be overridden (import)

View 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)

View file

@ -0,0 +1,5 @@
defaultVar: {{ .defaultVar }}
importVar: {{ .importVar }}
globalVar: {{ .globalVar }}
includeVar: {{ .includeVar }}
cliVar: {{ .cliVar }}