diff --git a/operator_test.go b/operator_test.go index 8106f666..00ca6225 100644 --- a/operator_test.go +++ b/operator_test.go @@ -408,8 +408,8 @@ func TestSkipIncluded(t *testing.T) { skipIncluded bool want int }{ - {"testdata/book/include_*", false, 3}, - {"testdata/book/include_*", true, 1}, + {"testdata/book/include_*", false, 5}, + {"testdata/book/include_*", true, 2}, } for _, tt := range tests { ops, err := Load(tt.paths, SkipIncluded(tt.skipIncluded), Runner("req", "https://api.github.com"), Runner("db", "sqlite://path/to/test.db")) @@ -501,6 +501,7 @@ func TestInclude(t *testing.T) { book string }{ {"testdata/book/include_main.yml"}, + {"testdata/book/include_vars.yml"}, } ctx := context.Background() for _, tt := range tests { diff --git a/testdata/book/include_vars_included.yml b/testdata/book/include_vars_included.yml new file mode 100644 index 00000000..ac391a50 --- /dev/null +++ b/testdata/book/include_vars_included.yml @@ -0,0 +1,21 @@ +desc: Include vars (included) +if: included +steps: + - + test: | + // If it is a primitive type, the value is passed as it is. + vars.a == 12345 + && vars.b == "54321" + // If there is a variable expansion, it is reinterpreted in a form without quotes. + && vars.c == 12345 + && vars.d == 54321 + && vars.e == 123459 + && vars.f == 543219 + && vars.g == 912345 + && vars.h == 954321 + // If cast with string(), it is treated as a string. + && vars.i == "12345" + && vars.j == "54321" + // If the expanded value is to be passed as a string, enclose it in double quotes. + && vars.k == "123459" + && vars.l == "543219" diff --git a/testdata/book/include_vars_main.yml b/testdata/book/include_vars_main.yml new file mode 100644 index 00000000..b14c65b5 --- /dev/null +++ b/testdata/book/include_vars_main.yml @@ -0,0 +1,25 @@ +desc: Include vars (main) +vars: + intNumber: 12345 + strNumber: "54321" +steps: + - + include: + path: include_vars_included.yml + vars: + # If it is a primitive type, the value is passed as it is. + a: 12345 + b: "54321" + # If there is a variable expansion, it is reinterpreted in a form without quotes. + c: '{{ vars.intNumber }}' + d: '{{ vars.strNumber }}' + e: '{{ vars.intNumber }}9' + f: '{{ vars.strNumber }}9' + g: '9{{ vars.intNumber }}' + h: '9{{ vars.strNumber }}' + # If cast with string(), it is treated as a string. + i: '{{ string(vars.intNumber) }}' + j: '{{ string(vars.strNumber) }}' + # If the expanded value is to be passed as a string, enclose it in double quotes. + k: '"{{ vars.intNumber }}9"' + l: '"{{ vars.strNumber }}9"'