Skip to content

CI: improve test assertions - #3777

Merged
mandre merged 4 commits into
gophercloud:mainfrom
shiftstack:test-assertions
Jun 8, 2026
Merged

mandre merged 4 commits into
gophercloud:mainfrom
shiftstack:test-assertions

Conversation

@mandre

@mandre mandre commented May 28, 2026 •

Copy link
Copy Markdown
Contributor

This PR does a few things:

  • fix the assertion argument order, for less confusing error messages
  • fix a couple of wrong assertions that silently passed
  • add new test helpers (AssertTrue, AssertFalse, AssertEqualsIgnoreCase, and their Check equivalents)
  • add missing assertions to validate fields set during test

mandre added 2 commits May 28, 2026 12:01
All equality assertion helpers (AssertEquals, CheckEquals, AssertDeepEquals,
CheckDeepEquals, etc.) expect (t, expected, actual) but many call sites had
the arguments swapped, putting the actual value first and the expected
literal second. This causes confusing error messages on test failure.
Fix bugs where assertions compared the wrong field or compared a value
to itself, silently passing due to empty string values.
@github-actions github-actions Bot added edit:networking This PR updates networking code edit:dns This PR updates dns code edit:image This PR updates image code edit:orchestration This PR updates orchestration code edit:db This PR updates db code edit:loadbalancer This PR updates loadbalancer code edit:compute This PR updates compute code edit:keymanager This PR updates keymanager code edit:messaging This PR updates messaging code edit:containerinfra This PR updates containerinfra code edit:objectstorage This PR updates objectstorage code edit:workflow This PR updates workflow code edit:sharedfilesystems This PR updates sharedfilesystems code edit:baremetal This PR updates baremetal code edit:gophercloud This PR updates common Gophercloud code edit:blockstorage This PR updates blockstorage code edit:identity This PR updates identity code edit:container This PR updates container code edit:baremetalintrospection This PR updates baremetalintrospection code labels May 28, 2026
@coveralls

coveralls commented May 28, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 63.519% (-0.5%) from 63.981% — shiftstack:test-assertions into gophercloud:main

@github-actions github-actions Bot added semver:patch No API change backport-v2 This PR will be backported to v2 labels May 28, 2026

@stephenfin stephenfin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like this still needs some work, but I have a suggestion inline. We can do that later also, given this is already quite large

Comment thread internal/acceptance/openstack/baremetal/httpbasic/allocations_test.go Outdated
@mandre
mandre force-pushed the test-assertions branch from 2931b23 to 52f83fc Compare May 28, 2026 13:12
@mandre mandre added the hold Do not merge label May 28, 2026
@github-actions github-actions Bot added edit:placement This PR updates placement code edit:testinfra This PR updates testing infrastructure code and removed semver:patch No API change labels May 28, 2026
@github-actions github-actions Bot added the semver:minor Backwards-compatible change label May 28, 2026
mandre added 2 commits May 28, 2026 17:54
Add AssertTrue, AssertFalse, CheckTrue, CheckFalse for boolean
assertions, and AssertEqualsIgnoreCase, CheckEqualsIgnoreCase for
case-insensitive string comparisons.

Replace all existing uses of AssertEquals and CheckEquals with boolean
literal arguments to use the new helpers instead.
Assert all fields that are set during Create and Update operations
across all acceptance tests. This ensures that returned objects contain
the expected values and helps catch field-mapping bugs.
@mandre
mandre force-pushed the test-assertions branch from 5e27a7e to 60117d2 Compare May 28, 2026 15:57
@mandre mandre removed the hold Do not merge label May 28, 2026
@mandre
mandre added this pull request to the merge queue Jun 8, 2026
Merged via the queue into gophercloud:main with commit e43f7b7 Jun 8, 2026
66 of 71 checks passed
@mandre
mandre deleted the test-assertions branch June 8, 2026 12:15
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Failed to backport PR to v2 branch. See logs for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-v2 This PR will be backported to v2 edit:baremetal This PR updates baremetal code edit:baremetalintrospection This PR updates baremetalintrospection code edit:blockstorage This PR updates blockstorage code edit:compute This PR updates compute code edit:container This PR updates container code edit:containerinfra This PR updates containerinfra code edit:db This PR updates db code edit:dns This PR updates dns code edit:gophercloud This PR updates common Gophercloud code edit:identity This PR updates identity code edit:image This PR updates image code edit:keymanager This PR updates keymanager code edit:loadbalancer This PR updates loadbalancer code edit:messaging This PR updates messaging code edit:networking This PR updates networking code edit:objectstorage This PR updates objectstorage code edit:orchestration This PR updates orchestration code edit:placement This PR updates placement code edit:sharedfilesystems This PR updates sharedfilesystems code edit:testinfra This PR updates testing infrastructure code edit:workflow This PR updates workflow code semver:minor Backwards-compatible change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants