From 6d39d294c18ae3dec8b34febfd136a92e97b2a6b Mon Sep 17 00:00:00 2001 From: Frederic BIDON Date: Wed, 10 Jun 2026 16:35:10 +0200 Subject: [PATCH] test: stop executing the live remote-URL doc examples ExampleSpec_second and ExampleSpecValidator_Validate_url load a spec from http://petstore.swagger.io/v2/swagger.json, a live host that intermittently returns HTTP 403, making the suite flaky. Drop their "// Output:" directives so Go still compiles them (they remain in godoc with the real URL and cannot bit-rot) but no longer runs them under go test. The remote path exercises loads.JSONSpec + network rather than validate logic, which is already covered by the file-based examples and tests, so executed coverage is not lost. A note on each example explains why the directive is intentionally absent. Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: Frederic BIDON --- doc_test.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/doc_test.go b/doc_test.go index b0ce7c9..53bcb13 100644 --- a/doc_test.go +++ b/doc_test.go @@ -57,8 +57,12 @@ func ExampleSpec_second() { fmt.Println("Could not load this spec:", err) } - // Output: - // This spec is valid + // NOTE: this example loads a spec from a live remote URL, so it is intentionally left + // without an "// Output:" directive: Go compiles it (keeping it from bit-rotting and + // displaying it in godoc with the real URL) but does not execute it under "go test". + // Executing it made the suite flaky (the remote host intermittently returns HTTP 403), + // and the remote path exercises loads.JSONSpec + network rather than validate itself, + // which is already covered by the file-based examples and tests. } func ExampleSpecValidator_Validate() { @@ -109,8 +113,12 @@ func ExampleSpecValidator_Validate_url() { } } - // Output: - // This spec is valid + // NOTE: this example loads a spec from a live remote URL, so it is intentionally left + // without an "// Output:" directive: Go compiles it (keeping it from bit-rotting and + // displaying it in godoc with the real URL) but does not execute it under "go test". + // Executing it made the suite flaky (the remote host intermittently returns HTTP 403), + // and the remote path exercises loads.JSONSpec + network rather than validate itself, + // which is already covered by the file-based examples and tests. } func ExampleAgainstSchema() {