test: strengthen P1 effect regression assertions (#146, #162)#193
test: strengthen P1 effect regression assertions (#146, #162)#193sonupreetam wants to merge 1 commit into
Conversation
yvonnedevlinrh
left a comment
There was a problem hiding this comment.
LGTM - the count + target pattern is a real improvement over boolean presence checks.
Two observations:
-
TestAnalyzeP1Effects_WrongWriteReturn — vacuously true assertions: HandleWrongWriteReturn produces zero effects, so both hasEffect checks pass trivially (an empty slice has no effects of any type). Consider adding if len(effects) != 0 { t.Errorf("expected no effects for WrongWriteReturn, got %d", len(effects)) } to explicitly assert the empty result. Without it, a future change that accidentally introduces a different effect type (e.g., some new call-expression effect) would pass undetected.
-
Partial #162 coverage: This PR covers the partial method set case (PartialResponseWriter) and one near-miss Write signature (Write([]byte) int), but #162 also lists three other near-miss cases (Write(string), Write([]byte) (int64, error), Write([]byte, int)) and suggests an internal unit test for matchesWriteSignature directly. If #162 gets closed after this PR merges, those cases would be silently dropped. Might be worth either adding them here (they're ~5-line fixture types each) or noting in #162 which items remain open.
c3bfb75 to
21e2569
Compare
|
@yvonnedevlinrh Thank you for catching this. I did the following:
|
21e2569 to
6c663a3
Compare
…nbound-force#162) - MapMutation/SliceMutation tests now assert exact count (1) and correct target name ("m"/"s") instead of boolean presence checks. - Add PartialResponseWriter fixture (Write+Header, no WriteHeader) to verify WriterOutput is emitted but HTTPResponseWrite is not. - Add WrongWriteReturn fixture (Write returns int, not (int, error)) to verify neither WriterOutput nor HTTPResponseWrite is emitted. Refs unbound-force#146 Refs unbound-force#162 Signed-off-by: sonupreetam <spreetam@redhat.com>
6c663a3 to
5e16f38
Compare
Summary
"m"/"s") instead of boolean presence checks. Applied at both the unit layer (p1effects_test.go) and integration layer (analysis_test.go).hasHTTPResponseWriterMethods/matchesWriteSignature:PartialResponseWriter(Write + Header, no WriteHeader) — verifiesWriterOutputis emitted butHTTPResponseWriteis not.WrongWriteReturn(Write returnsint, not(int, error)) — verifies neitherWriterOutputnorHTTPResponseWriteis emitted.Test plan
go test -race -count=1 -short ./internal/analysis/passesRefs #146, #162