From 9e52194ccfa7bacd016a0f5669353a10feacb759 Mon Sep 17 00:00:00 2001 From: Stephan Renatus Date: Fri, 11 Dec 2020 11:06:40 +0100 Subject: [PATCH] test/cases: disregard ordering in "strings/concat: set" test Since anything can happen, we now list the possibilities (3! = 6), and check that any of them was the result. Fixes #2924. Signed-off-by: Stephan Renatus --- internal/wasm/sdk/test/e2e/exceptions.yaml | 1 - .../testdata/strings/test-strings-0883.yaml | 104 +++--------------- 2 files changed, 17 insertions(+), 88 deletions(-) diff --git a/internal/wasm/sdk/test/e2e/exceptions.yaml b/internal/wasm/sdk/test/e2e/exceptions.yaml index 495578a0cb..436becbaf1 100644 --- a/internal/wasm/sdk/test/e2e/exceptions.yaml +++ b/internal/wasm/sdk/test/e2e/exceptions.yaml @@ -1,6 +1,5 @@ # Exception Format is : "baseandvirtualdocs/base/virtual: conflicts": "document merge conflict - https://github.com/open-policy-agent/opa/issues/2926" -"strings/concat: set": "test result order is not consistent - https://github.com/open-policy-agent/opa/issues/2924" "strings/format_int": "rounding error - https://github.com/open-policy-agent/opa/issues/2923" "strings/format_int: ref dest": "rounding error - https://github.com/open-policy-agent/opa/issues/2923" "strings/format_int: ref dest (2)": "rounding error - https://github.com/open-policy-agent/opa/issues/2923" diff --git a/test/cases/testdata/strings/test-strings-0883.yaml b/test/cases/testdata/strings/test-strings-0883.yaml index 4955668c3b..d469334ad4 100644 --- a/test/cases/testdata/strings/test-strings-0883.yaml +++ b/test/cases/testdata/strings/test-strings-0883.yaml @@ -1,95 +1,25 @@ cases: - data: - a: - - 1 - - 2 - - 3 - - 4 - b: - v1: hello - v2: goodbye - c: - - x: - - true - - false - - foo - "y": - - null - - 3.14159 - z: - p: true - q: false - d: - e: - - bar - - baz - f: - - xs: - - 1 - ys: - - 2 - - xs: - - 2 - ys: - - 3 - g: - a: - - 1 - - 0 - - 0 - - 0 - b: - - 0 - - 2 - - 0 - - 0 - c: - - 0 - - 0 - - 0 - - 4 - h: - - - 1 - - 2 - - 3 - - - 2 - - 3 - - 4 - l: - - a: bob - b: -1 - c: - - 1 - - 2 - - 3 - - 4 - - a: alice - b: 1 - c: - - 2 - - 3 - - 4 - - 5 - d: null - m: [] - numbers: - - "1" - - "2" - - "3" - - "4" - strings: - bar: 2 - baz: 3 - foo: 1 - three: 3 modules: - | - package generated + package test - p = x { - concat(",", {"1", "2", "3"}, x) + # Sets are unordered, so the output is not guaranteed. + # These are theoretically possible: + possibilities = { + "1,2,3", + "2,3,1", + "3,1,2", + "3,2,1", + "2,1,3", + "1,3,2" + } + + p { + x := concat(",", {"1", "2", "3"}) + possibilities[x] } note: 'strings/concat: set' - query: data.generated.p = x + query: data.test.p = x want_result: - - x: 1,2,3 + - x: true