Skip to content

test: add remaining matchesWriteSignature near-miss coverage (#162)#196

Draft
sonupreetam wants to merge 2 commits into
unbound-force:mainfrom
sonupreetam:test/162-matchesWriteSignature-near-misses
Draft

test: add remaining matchesWriteSignature near-miss coverage (#162)#196
sonupreetam wants to merge 2 commits into
unbound-force:mainfrom
sonupreetam:test/162-matchesWriteSignature-near-misses

Conversation

@sonupreetam

Copy link
Copy Markdown
Contributor

Summary

Stacked on #193. Completes the remaining test coverage requested in #162 (the partial coverage from #193 is noted in a comment).

Integration tests (3 new fixtures + tests)

Fixture Write signature Expected
WrongParamType Write(string) (int, error) no effects
WrongIntReturn64 Write([]byte) (int64, error) no effects
ExtraParamWrite Write([]byte, int) (int, error) no effects

Each test asserts len(effects) == 0 (non-vacuous) plus explicit !hasEffect checks for both HTTPResponseWrite and WriterOutput.

Internal unit test for matchesWriteSignature

Table-driven test (p1effects_internal_test.go) constructs synthetic *types.Signature values to exercise matchesWriteSignature directly — no package loading needed. Covers:

  • Valid: Write([]byte) (int, error) → true
  • Wrong param type: Write(string) (int, error) → false
  • Wrong int return: Write([]byte) (int64, error) → false
  • Extra param: Write([]byte, int) (int, error) → false
  • Missing error return: Write([]byte) int → false
  • No params: Write() (int, error) → false
  • No results: Write([]byte) → false

Test plan

  • go test -race -count=1 -short ./internal/analysis/ passes
  • All new assertions pass against existing implementation
  • CI green

Closes #162

…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>
…-force#162)

- Add 3 near-miss Write signature fixtures: WrongParamType (string param),
  WrongIntReturn64 (int64 return), ExtraParamWrite (extra param).
- Add integration tests verifying none produce WriterOutput or
  HTTPResponseWrite, with explicit len(effects)==0 guards.
- Add table-driven unit test for matchesWriteSignature via export_test.go,
  covering valid signature, all near-miss variants, and degenerate cases.

Closes unbound-force#162

Signed-off-by: sonupreetam <spreetam@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: add edge case coverage for hasHTTPResponseWriterMethods and matchesWriteSignature

1 participant