Refactor TestGetAuthorities into table-driven subtests - #1997
Open
nellshamrell wants to merge 2 commits into
Open
Refactor TestGetAuthorities into table-driven subtests#1997nellshamrell wants to merge 2 commits into
nellshamrell wants to merge 2 commits into
Conversation
Convert the monolithic TestGetAuthorities into named, table-driven subtests, resolving the long-standing TODO in image_policies_test.go. Each scenario now runs as its own t.Run subtest, so a failure reports which case broke and no longer aborts the remaining assertions. Panic- prone pointer/slice dereferences (nil Keyless.InsecureIgnoreSCT, indexing into Identities/Sources/Attestations/SignaturePullSecrets) are guarded so malformed fixtures produce clean failures instead of a panic that kills the whole test. This is a behavior-preserving, test-only change: the same assertions run with the same expected values as before. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0ce53efa-a7e9-4046-a24e-34c406601950 Signed-off-by: Nell Shamrell <nellshamrell@gmail.com>
nellshamrell
force-pushed
the
table-driven-getauthorities-test
branch
from
July 27, 2026 21:57
8aec297 to
179e935
Compare
Contributor
Author
|
Heads up: the failing CI on this PR is not related to these changes. It's a repo-wide breakage from an expired TUF
This should go green once #1999 is resolved. |
This was referenced Jul 28, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1997 +/- ##
=======================================
Coverage 30.73% 30.73%
=======================================
Files 122 122
Lines 7409 7409
=======================================
Hits 2277 2277
Misses 4897 4897
Partials 235 235 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
Converts the monolithic
TestGetAuthoritiesinpkg/apis/config/image_policies_test.gointo named, table-driven subtests, resolving the long-standing in-code TODO:// TODO: Clean up this test to be table-driven with sub-tests, instead of one big test.Motivation
The original test ran ~15 independent scenarios sequentially against one shared config. A single
t.Fatalf(e.g. via thegetAuthorityhelper) aborted all remaining assertions, and failures reported generic messages with no indication of which scenario broke.Changes
t.Runsubtest, so failures are isolated and clearly named (--- FAIL: TestGetAuthorities/keyless_authority, etc.).Keyless.InsecureIgnoreSCT, indexing intoIdentities/Sources/Attestations/SignaturePullSecrets) are guarded so a malformed fixture yields a clean subtest failure instead of a panic.Behavior preservation
This is a test-only, behavior-preserving refactor: the same assertions run with the same expected values as before. No production code is touched.
Testing
All pass / clean.