feat: regenerate & document fixture files for UF presenter test suite#634
feat: regenerate & document fixture files for UF presenter test suite#634robertolopezlopez wants to merge 5 commits into
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
/describe |
|
Preparing PR description... |
bf9312b to
cc3a045
Compare
This comment has been minimized.
This comment has been minimized.
| require.NoError(t, err) | ||
| require.Len(t, testResults, 1) | ||
|
|
||
| expectedFindings, complete, err := testResults[0].Findings(ctx) |
There was a problem hiding this comment.
Should Fix — this change defangs Test_Findings_ConcurrentAccess. The new pre-loop call testResults[0].Findings(ctx) performs the lazy ReconstructFindings once, single-threaded, and memoizes into fullFindings. All 10 goroutines below then hit the fullFindings != nil fast-return and never exercise the concurrent first-access reconstruction path — which is the exact code this test exists to guard. A future race introduced in lazy reconstruction would now pass clean under -race.
Two fixes, ideally both:
- Derive
expectedCountwithout warming the object under test — e.g. parse the bytes into a separateNewSerializableTestResultFromBytesinstance (or countFindingsData/ProblemRefs), sotestResults[0]is still cold when the goroutines first hit it. - The old
require.Len(..., 47)also guaranteed a non-trivial payload; the dynamicexpectedCountpasses vacuously if the fixture ever regenerates to 0 findings. Addrequire.Greater(t, expectedCount, 0)(or restore an absolute count, e.g.55).
— AI review
There was a problem hiding this comment.
addressed with latest commit - thanks!
Verdict: well-documented, coherent fixture regeneration. Strong positive signal: the regeneration reflects a real behaviour change (switch to OSS unified Should Fix (inline)
Suggestions (non-blocking)
— AI review |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| @@ -1,128 +1,109 @@ | |||
| [1mTesting (package.json) ...[0m | |||
| [1mTesting (package-lock.json) ...[0m | |||
There was a problem hiding this comment.
Should Fix (test coverage) — reachability rendering is no longer exercised by any fixture. Regenerating these inputs via the OSS snyk test path dropped all reachability data: testresult_cli.json went 26→0 reachability entries and webgoat.ignore.testresult.json 47→0, so every Reachability: … line disappeared from the golden output (cli.human.readable 9→0, webgoat.ignore.human.readable 42→0). The UFM presenter still renders reachability, but after this PR no fixture covers that branch — a future regression that breaks reachability rendering would pass the whole UFM golden suite clean.
This is new since my last review (the cli fixture also switched package.json→package-lock.json, which is what dropped the reachability-bearing input).
Suggest either retaining/adding one fixture that carries reachability data so the branch stays covered, or documenting in the README that reachability output is intentionally untested post-CLI-1510 with a follow-up ticket.
— AI review
| cp dumps/testresult_cli.testresult.json internal/presenters/testdata/ufm/testresult_cli.json | ||
| ``` | ||
|
|
||
| Verify: `metadata.project-name` is `snyk`, `display-target-file` is `package.json`. |
There was a problem hiding this comment.
Suggestion (doc/fixture drift) — testresult_cli target-file claim contradicts the regenerated fixture. This line (and the catalog row at the top) say display-target-file is package.json, but the regenerated cli.human.readable now reports Testing (package-lock.json) — the new commits switched the cli scan to the lockfile. Update the README verify step to package-lock.json so a contributor regenerating doesn't think the run drifted.
— AI review
Prior round resolved. The three items I flagged last time are addressed by the new commits: the New since last review:
Other suggestions (non-blocking):
— AI review |
This comment has been minimized.
This comment has been minimized.
1547c6d to
e001b7b
Compare
This comment has been minimized.
This comment has been minimized.
| # unified path emits workflow.TestResult payloads we need. Config honors this env var | ||
| # before the org FF gateway (see CLI-1510). Not needed for `secrets test`. | ||
| if is_oss_test_scan; then | ||
| export INTERNAL_SNYK_CLI_USE_UNIFIED_TEST_API_FOR_OS_CLI_TEST="${INTERNAL_SNYK_CLI_USE_UNIFIED_TEST_API_FOR_OS_CLI_TEST:-true}" |
There was a problem hiding this comment.
Suggestion (non-blocking): this export runs before the PROJECT/ORG/NAME validation block at lines 32-42. If the script is sourced (. ./generate-fixture.sh) rather than executed, and validation exits early, INTERNAL_SNYK_CLI_USE_UNIFIED_TEST_API_FOR_OS_CLI_TEST=true leaks into the caller's interactive shell and silently affects later manual snyk runs. Moving the export to after the validation block (it's only needed at scan time) avoids the leak. In the normal executed-as-subprocess path this is harmless. — AI review
|
This comment has been minimized.
This comment has been minimized.
48ca41f to
a529b81
Compare
This comment has been minimized.
This comment has been minimized.
a529b81 to
cf9ee1e
Compare
PR Reviewer Guide 🔍
|
| require.NoError(t, err) | ||
| require.Len(t, testResults, 1) | ||
|
|
||
| expectedResults, err := NewSerializableTestResultFromBytes(testResultsData) |
There was a problem hiding this comment.
issue: I think I understand what the intention of this was, but it's asserting the same thing against each other 😅 since just above testResults is going the same function call
testResults, err := NewSerializableTestResultFromBytes(testResultsData)
Description
This PR regenerates and documents UFM presenter live fixtures.
Fixture catalog, workflow
internal/presenters/testdata/ufm/README.mdwith per-fixture information.CONTRIBUTING.mdgenerate-fixturefixINTERNAL_SNYK_CLI_USE_UNIFIED_TEST_API_FOR_OS_CLI_TEST=truefortest*scans so OSSsnyk testemitsworkflow.TestResultdumps (legacycli path does not).Live fixture refresh (platform_hammerhead_testing)
testresult_cli-snyk test .onsnyk/cliwebgoat/webgoat.ignore-snyk test .on OWASP WebGoat Java (shared input; expected output differs by test config)Live fixture refresh (
platform_hammerhead_testing)testresult_cli-snyk test .onsnyk/cliwebgoat/webgoat.ignore-snyk test .on OWASP WebGoat Java (shared input; expected output differs by test config)multi_project
tpwe(.NET) sub-project from committedmulti_project.testresult.jsonandmulti_project.sarif.json(personal project, no maintained source checkout).Extra
go-gitbump to 5.19.0 because of thistestifybump to 1.11.1 is automatic aftergo mod tidyChecklist
make test)make generate)make lint)go get github.com/snyk/go-application-framework@YOUR_LATEST_GAF_COMMITin thecliv2directory.go.modto point to your local GAF code.go mod tidyin thecliv2directory.go.modandgo.sumchanges.