Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Improve usage of lxd sql in tests #14674

Merged
merged 11 commits into from
Dec 17, 2024
Merged

Conversation

markylaing
Copy link
Contributor

Support for the --format flag was added in #14670. This PR uses the format flag where possible in our test suite to avoid e.g. grepping for table formatted output.

In some cases I've changed queries to use a SELECT count(*) FROM ... instead of a SELECT * FROM ... where the output was piped into a word count or grepped with the -c flag.

This grep will never have been asserting anything since the instance name
is not present in the `auth_groups_permissions` table. Instead we now
assert that there are no permissions with the `can_exec` entitlement via `count`.

Signed-off-by: Mark Laing <[email protected]>
Using csv here should mean this test is not subject to any formatting
differences before and after backup.

Signed-off-by: Mark Laing <[email protected]>
Using a count query here because grepping for things that we don't expect
to be there can be error prone.

Signed-off-by: Mark Laing <[email protected]>
With `--format csv` it's easier to perform the exact match.

Signed-off-by: Mark Laing <[email protected]>
With `--format csv` it's easier to perform the exact match.

Signed-off-by: Mark Laing <[email protected]>
Using `count` with `--format csv` to show that the node count is decremented
when the node is forcefully removed.

Signed-off-by: Mark Laing <[email protected]>
Now checking for exact matches. `cut -c-1-12` is used on returned fingerprints
to match against what is shown in the CLI.

Signed-off-by: Mark Laing <[email protected]>
Using `count` and `--format csv` we can assert the user is present in the
database without `wc -l`.

Signed-off-by: Mark Laing <[email protected]>
This simplifies the assertion that the username is present in `GET /1.0`
output and additionally asserts that the `auth` field is `trusted`.

Signed-off-by: Mark Laing <[email protected]>
@markylaing markylaing self-assigned this Dec 17, 2024
Copy link
Member

@simondeziel simondeziel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely, thanks!

@tomponline tomponline merged commit e57536c into canonical:main Dec 17, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants