Skip to content

Fix bytes.Reader issues #1055

Open
ckbaker10 wants to merge 3 commits into
goss-org:masterfrom
ckbaker10:fix-byte-reader
Open

Fix bytes.Reader issues #1055
ckbaker10 wants to merge 3 commits into
goss-org:masterfrom
ckbaker10:fix-byte-reader

Conversation

@ckbaker10

Copy link
Copy Markdown
Checklist
  • make test-all (UNIX) passes. CI will also test this
  • unit and/or integration tests are included (if applicable)
  • documentation is changed or added (if applicable)

Description of change

file resource contents checks always reported object: *bytes.Reader on failure instead of the actual file content, making it completely useless for debugging.

Root cause: in ValidateGomegaValue, the func() (io.Reader, error) switch arm called f() and passed the raw io.Reader as foundValue to HavePatterns. The matcher scanned it fine, but once consumed, FailureResult had nothing left to read and fell through to fmt.Sprintf("object: %T", actual).

Fix: materialize the reader into a string immediately in the switch arm before handing it to the matcher. HavePatterns already handles string input, and FailureResult already formats strings correctly — so no changes needed there.

Updated three golden test fixtures that were asserting the broken "object: *strings.Reader" output.

@kgaughan

kgaughan commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

I'm hoping I can get this merged in a subsequent release. It's borderline between a bugfix and a behavioural change, but it's definitely worth fixing, if only because I hit this issue when fixing other bugs.

In the meantime, would you mind merging from master?

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.

2 participants