Skip to content

Commit

Permalink
chore: Adjust e2e tests for createdAt and createdBy new v1alpha Proje…
Browse files Browse the repository at this point in the history
…ct.Spec fields (#144)

## Motivation

With the introduction of new server-side computed fields for v1alpha
Project.Spec: `createdAt` and `createdBy` the tests started failing as
the helper function `_assert_objects_existence` was comparing almost the
whole object.
This is too much for a simple assertion that checks if the object was
actually applied, so I added additional filter to re-map the objects,
extracting the basic minimum for comparison.

## Related Changes

- nobl9/nobl9-go#422

## Testing

Run `make test/e2e`, remember about supplying the right env vars OR run
https://github.com/nobl9/sloctl/actions/workflows/e2e-tests-dispatch.yml
with this branch as target.
  • Loading branch information
nieomylnieja committed Jun 11, 2024
1 parent 8f82d63 commit b55268a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/test_helper/load.bash
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,19 @@ _assert_objects_existence() {
case "$1" in
apply)
run_sloctl "${args[*]}"
refute_output --partial "No resources found"
# We can't retrieve the same object we applied so we need to compare the minimum.
filter='[.[] | {"name": .metadata.name, "project": .metadata.project, "labels": .metadata.labels, "annotations": .metadata.annotations}] | sort_by(.name, .project)'
# shellcheck disable=2154
have=$(yq --sort-keys -y '[.[] | del(.status)]' <<<"$output")
have=$(yq --sort-keys -y "$filter" <<<"$output")
want=$(yq --sort-keys -y '[
.[] | select(.kind == "'"$kind"'") |
select(.metadata.name == "'"$name"'") |
if .metadata.project then
select(.metadata.project == "'"$project"'")
else
.
end]' <<<"$2")
end] | '"$filter"'' <<<"$2")
assert_equal "$have" "$want"
;;
delete)
Expand Down

0 comments on commit b55268a

Please sign in to comment.