test(admin): adopt echotest and testify in admin, auditlog, and cache tests - #982
test(admin): adopt echotest and testify in admin, auditlog, and cache tests#982SantiagoDePolonia wants to merge 3 commits into
Conversation
|
Warning Review limit reachedNext included review available in 11 minutes. View limit detailsLimit details: You’ve used all 4 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (64)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| assert.NotNil(t, models[0].TotalCost) | ||
| assert.Equal(t, 1.5, *models[0].TotalCost) |
There was a problem hiding this comment.
Require pointers before dereferencing
assert.NotNil records a failure but allows this test to continue, so a nil decoded TotalCost then panics at the following dereference instead of reporting the useful contract failure. Use require.NotNil before this dereference and the equivalent checks at lines 547 and 587. This is non-blocking, but it makes response-decoding regressions harder to diagnose.
Artifacts
- A temporary Go test defines the assert-and-dereference and require-and-dereference nil-pointer patterns used for the runtime comparison; it directly reproduces the relevant control flow.
- Two executed `go test` runs show that the assert pattern reports nil then panics, while the require pattern reports nil and terminates without a panic; require preserves the intended diagnostic.
|
The three |
Rewrites the
internal/admin,internal/auditlog,internal/responsecache, andinternal/telemetrytests on top of the sharedechotesthelper and testify.newHandlerContextand decode helpers becomeechotest.Get/Post/Requestandechotest.Decode;echo.New()remains only where the real router is exercised.require/assert; pointer identity checks useNotSame.admin/dashboard,TestParseUsageParams_IntervalEmpty(identical to an assertion inTestParseUsageParams_DaysDefault), the two recalculate-confirmation tests and the slash-in-name credential test folded into tables,TestNoopLogger(does-not-panic),TestSQLStore_WriteBatch_Chunking(covered by the boundary and parameter-limit tests), and the two identical cache-control skip tests merged into one.Test-only change, about 5,800 net lines removed. Stacked on #976 (helper packages).