Skip to content

Commit

Permalink
tests: check that rules have unique path patterns
Browse files Browse the repository at this point in the history
Signed-off-by: Oliver Calder <[email protected]>
  • Loading branch information
olivercalder committed Jan 14, 2025
1 parent 8435c13 commit 024d155
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ if [ "$CLIENT_OUTPUT" != "success" ] ; then
echo "output='$CLIENT_OUTPUT'"
exit 1
fi
# Furthermore, rules with identical path patterns are merged, so we don't
# expect any rules with duplicate path patterns.
snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | MATCH '^[[:space:]]*1'
snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | NOMATCH '^[[:space:]]*2'

TEST_OUTPUT="$(cat "${TEST_DIR}/Downloads/test.txt")"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ if [ "$CLIENT_OUTPUT" != "success" ] ; then
exit 1
fi

# Rules with identical path patterns are merged, so we don't expect any rules
# with duplicate path patterns.
snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | MATCH '^[[:space:]]*1'
snap debug api /v2/interfaces/requests/rules | jq '."result".[]."constraints"."path-pattern"' | grep "${TEST_DIR}" | uniq -c | NOMATCH '^[[:space:]]*2'

TEST_OUTPUT="$(cat "${TEST_DIR}/Downloads/test.txt")"

if [ "$TEST_OUTPUT" != "it is written" ] ; then
Expand Down

0 comments on commit 024d155

Please sign in to comment.