Use bats-assert library functions in BATS test suite - #2018
Merged
PromoFaux merged 3 commits intoMar 30, 2026
Conversation
Agent-Logs-Url: https://github.com/pi-hole/docker-pi-hole/sessions/a7bafe62-d413-4878-8d02-520f208d2812 Co-authored-by: PromoFaux <1998970+PromoFaux@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update BATS tests based on comments from Casperklein
Use bats-assert library functions in BATS test suite
Mar 30, 2026
PromoFaux
marked this pull request as ready for review
March 30, 2026 10:27
PromoFaux
approved these changes
Mar 30, 2026
PromoFaux
reviewed
Mar 30, 2026
Signed-off-by: Adam Warner <github@adamwarner.co.uk>
yubiuser
approved these changes
Mar 30, 2026
|
The changelog suggests this to be the first AI generated code in pi-hole–sort of, since this only affects code test. Does the project plan on writing an AI code policy, to make the use of such code and its review process transparent to users? |
Member
Sounds reasonable. |
Member
|
I don't suppose I've ever really considered it. Can you point to some other projects that implement such a policy? |
|
@PromoFaux Sure, there are plenty. The arguments for and against AI generated code are rather well hashed out already. I link to the Linux policy as an example, as others are to be found. There is probably a better place for discussion, than this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As suggested by @casperklein, replace manual shell assertions with
bats-assertlibrary functions for cleaner tests and better failure output (expected vs. actual diffs on failure).Changes
test/run.sh: Installbats-supportandbats-assertalongsidebats-core, pinned to specific versions (v0.3.0/v2.1.0) and overridable viaBATS_SUPPORT_VERSION/BATS_ASSERT_VERSIONtest/test_suite.bats: Load the libraries and replace manual assertions throughout:[ "$status" -eq 0 ]→assert_success[[ "$output" == *"..."* ]]→assert_output --partial "..."[ "$output" = "..." ]→assert_output "..."run), pipe throughrun echo "$logs"to makeassert_output --partialusableBefore / After