Skip to content

tests: make schema fixtures deterministic#273

Merged
fredbi merged 5 commits into
go-openapi:masterfrom
HNO3Miracle:hno3/wait-for-fixture-server
Jul 23, 2026
Merged

tests: make schema fixtures deterministic#273
fredbi merged 5 commits into
go-openapi:masterfrom
HNO3Miracle:hno3/wait-for-fixture-server

Conversation

@HNO3Miracle

@HNO3Miracle HNO3Miracle commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

This PR removes two sources of nondeterminism from the validation examples and schema tests:

  • Create the local fixture listener synchronously before serving, so requests cannot race ListenAndServe.
  • Use the repository-bundled Petstore document in examples instead of fetching petstore.swagger.io.

The cleanup path accepts the expected http.ErrServerClosed.

Tested with go test ./....

TestJSONSchemaSuite started the HTTP fixture server in a goroutine and immediately ran parallel tests, allowing clients to connect before the listener was ready. Create the listener synchronously and close the server during cleanup to remove the race.

Signed-off-by: HNO3Miracle <xiangao.or@isrc.iscas.ac.cn>
The documentation examples should not depend on petstore.swagger.io. Load the
repository fixture instead so the examples remain deterministic and work in
offline build environments.

Signed-off-by: HNO3Miracle <xiangao.or@isrc.iscas.ac.cn>
@HNO3Miracle HNO3Miracle changed the title tests: wait for the local fixture server tests: make schema fixtures deterministic Jul 22, 2026
@fredbi

fredbi commented Jul 22, 2026

Copy link
Copy Markdown
Member

Let's see if the magic works :)

Signed-off-by: HNO3Miracle <xiangao.or@isrc.iscas.ac.cn>

@fredbi fredbi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Moving up the test server is indeed a good improvement.

Could you just reinstate the comment in the example as suggested?

Comment thread doc_test.go
Signed-off-by: HNO3Miracle <xiangao.or@isrc.iscas.ac.cn>
@HNO3Miracle HNO3Miracle reopened this Jul 23, 2026
@HNO3Miracle

Copy link
Copy Markdown
Contributor Author

Force refreshed this PR :)

Signed-off-by: HNO3Miracle <xiangao.or@isrc.iscas.ac.cn>
@HNO3Miracle HNO3Miracle reopened this Jul 23, 2026
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.37%. Comparing base (9b81767) to head (7053c02).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #273      +/-   ##
==========================================
+ Coverage   92.31%   92.37%   +0.06%     
==========================================
  Files          24       24              
  Lines        3280     3280              
==========================================
+ Hits         3028     3030       +2     
+ Misses        166      165       -1     
+ Partials       86       85       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@fredbi
fredbi merged commit 7e0ebfa into go-openapi:master Jul 23, 2026
21 checks passed
@fredbi

fredbi commented Jul 23, 2026

Copy link
Copy Markdown
Member

Thank you for this fix

@HNO3Miracle
HNO3Miracle deleted the hno3/wait-for-fixture-server branch July 23, 2026 09:48
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