From 79bc5273f3e386872d885a988811dd4d7bd2a242 Mon Sep 17 00:00:00 2001 From: k2tzumi Date: Sat, 28 Oct 2023 10:16:36 +0900 Subject: [PATCH 1/3] Test that a string containing numbers is not interpreted as a number when included in vars. --- operator_test.go | 1 + testdata/book/include_loop.yml | 14 ++++++++++++++ testdata/book/include_str_int.yml | 9 +++++++++ 3 files changed, 24 insertions(+) create mode 100644 testdata/book/include_loop.yml create mode 100644 testdata/book/include_str_int.yml diff --git a/operator_test.go b/operator_test.go index 8106f666..3c57db02 100644 --- a/operator_test.go +++ b/operator_test.go @@ -259,6 +259,7 @@ func TestRunUsingLoop(t *testing.T) { book string }{ {"testdata/book/loop.yml"}, + {"testdata/book/include_loop.yml"}, } ctx := context.Background() for _, tt := range tests { diff --git a/testdata/book/include_loop.yml b/testdata/book/include_loop.yml new file mode 100644 index 00000000..f7b990de --- /dev/null +++ b/testdata/book/include_loop.yml @@ -0,0 +1,14 @@ +desc: Test include loop +vars: + lists: + - 1 + - 2 + - 3 +steps: + include_loop: + loop: len(vars.lists) + include: + path: include_str_int.yml + vars: + a: '010000000{{ i }}' + b: '1601{{ i }}' diff --git a/testdata/book/include_str_int.yml b/testdata/book/include_str_int.yml new file mode 100644 index 00000000..054b38e6 --- /dev/null +++ b/testdata/book/include_str_int.yml @@ -0,0 +1,9 @@ +desc: For include loop test +vars: + a: null + b: null +steps: + t_main: + test: | + vars.a == "0100000001" + && vars.b == "16011" From 2e69348382c537a193d09724e8221724a5a20581 Mon Sep 17 00:00:00 2001 From: k2tzumi Date: Sat, 28 Oct 2023 10:28:02 +0900 Subject: [PATCH 2/3] include was not involved --- testdata/book/include_loop.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/testdata/book/include_loop.yml b/testdata/book/include_loop.yml index f7b990de..3453325c 100644 --- a/testdata/book/include_loop.yml +++ b/testdata/book/include_loop.yml @@ -1,14 +1,14 @@ -desc: Test include loop +desc: Test include loop(include was not involved.) vars: lists: - 1 - 2 - 3 + int: 1 steps: - include_loop: - loop: len(vars.lists) + include_not_loop: include: path: include_str_int.yml vars: - a: '010000000{{ i }}' - b: '1601{{ i }}' + a: '010000000{{ vars.int }}' + b: '1601{{ vars.int }}' From a251a90c192d7155ed64cba32135a9f74b6051a8 Mon Sep 17 00:00:00 2001 From: k2tzumi Date: Sat, 28 Oct 2023 11:21:05 +0900 Subject: [PATCH 3/3] add --- include_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include_test.go b/include_test.go index 17e935cf..0755bd2d 100644 --- a/include_test.go +++ b/include_test.go @@ -18,6 +18,15 @@ func TestIncludeRunnerRun(t *testing.T) { {"testdata/book/db.yml", map[string]any{}, 8}, {"testdata/book/db.yml", map[string]any{"foo": "bar"}, 8}, {"testdata/book/db.yml", map[string]any{"json": "json://../vars.json"}, 8}, + { + "testdata/book/include_str_int.yml", + map[string]any{ + "a": "010000000{{ vars.int }}", + "b": "1601{{ vars.int }}", + "int": 1, + }, + 1, + }, } ctx := context.Background() for _, tt := range tests {