Skip to content

Add hammy reader assertions#4

Merged
nfisher merged 1 commit into
mainfrom
codex/create-reader-assertions-in-hammy/reader.go
Jun 16, 2026
Merged

Add hammy reader assertions#4
nfisher merged 1 commit into
mainfrom
codex/create-reader-assertions-in-hammy/reader.go

Conversation

@nfisher

@nfisher nfisher commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Motivation

  • Add reader-focused assertions to Hammy so tests can assert io.Reader contents (string/bytes) and emptiness using the same style as existing buffer assertions.
  • Ensure assertions are practical for real readers by documenting and handling the fact that reading consumes the supplied io.Reader and by reusing a buffered copy for repeated assertions.

Description

  • Add Reader(actual io.Reader) *ReaderAssert and a ReaderAssert type in hammy/reader.go with methods EqualToString, ContainsString, EqualToBytes, IsEmpty, and NotEmpty implemented to return AssertionMessage results.
  • Implement a readAll helper that reads and caches the reader body on first use, returns clear failure messages for nil readers and read errors, and reuses the cached body for subsequent assertions.
  • Document the reader-consumption behavior in the file-level comment so callers know that the supplied reader is consumed unless it implements its own buffering/reset.
  • Add hammy/reader_test.go with tests covering success and failure cases for each assertion, nil-reader and read-error handling, and verification that the buffered body is reused after the first read.

Testing

  • Ran go test ./... and all tests passed successfully.

Codex Task

@nfisher nfisher merged commit e02d009 into main Jun 16, 2026
1 check passed
@nfisher nfisher deleted the codex/create-reader-assertions-in-hammy/reader.go branch June 16, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant