Skip to content

Commit e142b51

Browse files
fredbiclaude
andauthored
test: rename the fixtures directory to testdata (#283)
Test material now lives in testdata/. The Go toolchain gives testdata a defined meaning — package patterns, vet and the build all skip it — whereas fixtures/ was ours alone. update-fixtures.sh, which refreshes the JSON-Schema-Test-Suite copy, is renamed to update-testdata.sh and writes to the new location. Nothing referenced it by name. Comments that name the directory are updated; those using "fixtures" for test material in general keep their wording. The x-go-package in go-swagger/bugs/981 follows the same move upstream, so it now reads go-swagger/testdata/bugs/981. Signed-off-by: Frederic BIDON <fredbi@yahoo.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 5a10341 commit e142b51

372 files changed

Lines changed: 151 additions & 151 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎benchmark_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
func Benchmark_KubernetesSpec(b *testing.B) {
16-
fp := filepath.Join("fixtures", "go-swagger", "canary", "kubernetes", "swagger.json")
16+
fp := filepath.Join("testdata", "go-swagger", "canary", "kubernetes", "swagger.json")
1717
doc, err := loads.Spec(fp)
1818
require.NoError(b, err)
1919
require.NotNil(b, doc)

‎default_validator_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestDefault_ValidateDefaults(t *testing.T) {
6868
}
6969

7070
for _, tt := range tests {
71-
path := filepath.Join("fixtures", "validation", "default", "valid-default-value-"+tt+jsonExt)
71+
path := filepath.Join("testdata", "validation", "default", "valid-default-value-"+tt+jsonExt)
7272
if DebugTest {
7373
t.Logf("Testing valid default values for: %s", path)
7474
}
@@ -83,7 +83,7 @@ func TestDefault_ValidateDefaults(t *testing.T) {
8383
assert.SliceContainsT(t, warns, "limit in query has a default value and is required as parameter")
8484
}
8585

86-
path = filepath.Join("fixtures", "validation", "default", "invalid-default-value-"+tt+jsonExt)
86+
path = filepath.Join("testdata", "validation", "default", "invalid-default-value-"+tt+jsonExt)
8787
if DebugTest {
8888
t.Logf("Testing invalid default values for: %s", path)
8989
}

‎deterministic_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ func TestDeterministic_FullReport(t *testing.T) {
125125
const runs = 20
126126

127127
for _, fixture := range []string{
128-
filepath.Join("fixtures", "validation", "fixture-1231.yaml"),
129-
filepath.Join("fixtures", "validation", "fixture-additional-items-invalid-values.yaml"),
130-
filepath.Join("fixtures", "validation", "fixture-342.yaml"),
128+
filepath.Join("testdata", "validation", "fixture-1231.yaml"),
129+
filepath.Join("testdata", "validation", "fixture-additional-items-invalid-values.yaml"),
130+
filepath.Join("testdata", "validation", "fixture-342.yaml"),
131131
} {
132132
t.Run(filepath.Base(fixture), func(t *testing.T) {
133133
t.Parallel()

‎doc_test.go‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func ExampleSpec() {
2121
// Example with high level spec validation call, without showing warnings
2222

2323
// Example with spec file in this repo:
24-
path := "fixtures/validation/valid-ref.json"
24+
path := "testdata/validation/valid-ref.json"
2525
doc, err := loads.Spec(path)
2626
if err == nil {
2727
validate.SetContinueOnErrors(true) // Set global options
@@ -43,7 +43,7 @@ func ExampleSpec_second() {
4343

4444
// Example with the bundled Petstore spec:
4545
// Also works with URL, e.g. http://petstore.swagger.io/v2/swagger.json
46-
path := "fixtures/go-swagger/canary/petstore/swagger.json"
46+
path := "testdata/go-swagger/canary/petstore/swagger.json"
4747
doc, err := loads.JSONSpec(path)
4848
if err == nil {
4949
validate.SetContinueOnErrors(true) // Set global options
@@ -74,7 +74,7 @@ func ExampleSpecValidator_Validate() {
7474
// doc, err := loads.JSONSpec(url)
7575

7676
// Example with spec file in this repo:
77-
path := "fixtures/validation/valid-ref.json"
77+
path := "testdata/validation/valid-ref.json"
7878
doc, err := loads.Spec(path)
7979
if err == nil {
8080
validator := validate.NewSpecValidator(doc.Schema(), strfmt.Default)
@@ -99,7 +99,7 @@ func ExampleSpecValidator_Validate_url() {
9999

100100
// Example with the bundled Petstore spec:
101101
// Also works with URL, e.g. http://petstore.swagger.io/v2/swagger.json
102-
path := "fixtures/go-swagger/canary/petstore/swagger.json"
102+
path := "testdata/go-swagger/canary/petstore/swagger.json"
103103
doc, err := loads.JSONSpec(path)
104104
if err == nil {
105105
validator := validate.NewSpecValidator(doc.Schema(), strfmt.Default)
@@ -191,8 +191,8 @@ func getSimpleSchema() *spec.Schema {
191191
func Test_Issue102_Circular(t *testing.T) {
192192
// assert that the issue is fixed in go-openapi/spec
193193
for _, fixture := range []string{
194-
filepath.Join("fixtures", "bugs", "102", "fixture-102.json"),
195-
filepath.Join("fixtures", "bugs", "123-validate", "fixture-123.json"),
194+
filepath.Join("testdata", "bugs", "102", "fixture-102.json"),
195+
filepath.Join("testdata", "bugs", "123-validate", "fixture-123.json"),
196196
} {
197197
t.Run(fixture, func(t *testing.T) {
198198
filebytes, err := os.ReadFile(fixture)

‎example_validator_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestExample_ValidateExamples(t *testing.T) {
5050
}
5151

5252
for _, tt := range tests {
53-
path := filepath.Join("fixtures", "validation", "example", "valid-example-"+tt+".json")
53+
path := filepath.Join("testdata", "validation", "example", "valid-example-"+tt+".json")
5454
if DebugTest {
5555
t.Logf("Testing valid example values for: %s", path)
5656
}
@@ -67,7 +67,7 @@ func TestExample_ValidateExamples(t *testing.T) {
6767
*/
6868
debugTest(t, path, res)
6969

70-
path = filepath.Join("fixtures", "validation", "example", "invalid-example-"+tt+".json")
70+
path = filepath.Join("testdata", "validation", "example", "invalid-example-"+tt+".json")
7171

7272
if DebugTest {
7373
t.Logf("Testing invalid example values for: %s", path)

‎items_validator_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var (
2727
)
2828

2929
func init() {
30-
petstoreFixture := filepath.Join("fixtures", "petstore", "swagger.json")
30+
petstoreFixture := filepath.Join("testdata", "petstore", "swagger.json")
3131
petstore, err := os.ReadFile(petstoreFixture)
3232
if err != nil {
3333
log.Fatalf("could not initialize fixture: %s: %v", petstoreFixture, err)

‎jsonschema_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ type schemaTestT struct {
3333
}
3434

3535
var (
36-
jsonSchemaFixturesPath = filepath.Join("fixtures", "jsonschema_suite")
37-
schemaFixturesPath = filepath.Join("fixtures", "schemas")
38-
formatFixturesPath = filepath.Join("fixtures", "formats")
36+
jsonSchemaFixturesPath = filepath.Join("testdata", "jsonschema_suite")
37+
schemaFixturesPath = filepath.Join("testdata", "schemas")
38+
formatFixturesPath = filepath.Join("testdata", "formats")
3939
)
4040

4141
func enabled() []string {

‎messages_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ func testMessageQuality(t *testing.T, haltOnErrors bool, continueOnErrors bool)
101101
// set SWAGGER_DEBUG_TEST=1 env to get a report of messages at the end of each test.
102102
// expectedMessage{"", false, false},
103103
//
104-
// expected messages and warnings are configured in ./fixtures/validation/expected_messages.yaml
104+
// expected messages and warnings are configured in ./testdata/validation/expected_messages.yaml
105105
//
106106
var errs int // error count
107107

108-
tested := loadTestConfig(t, filepath.Join("fixtures", "validation", "expected_messages.yaml"))
108+
tested := loadTestConfig(t, filepath.Join("testdata", "validation", "expected_messages.yaml"))
109109

110-
if err := filepath.Walk(filepath.Join("fixtures", "validation"), testWalkSpecs(t, tested, haltOnErrors, continueOnErrors)); err != nil {
110+
if err := filepath.Walk(filepath.Join("testdata", "validation"), testWalkSpecs(t, tested, haltOnErrors, continueOnErrors)); err != nil {
111111
t.Logf("%v", err)
112112
errs++
113113
}
@@ -433,6 +433,6 @@ func testIssue(t *testing.T, path string, expectedNumErrors, expectedNumWarnings
433433
// Test unitary fixture for dev and bug fixing.
434434
func Test_SingleFixture(t *testing.T) {
435435
t.SkipNow()
436-
path := filepath.Join("fixtures", "validation", "fixture-1231.yaml")
436+
path := filepath.Join("testdata", "validation", "fixture-1231.yaml")
437437
testIssue(t, path, -1, -1)
438438
}

‎pointer_resolution_test.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ func TestPointerResolution_EveryFixture(t *testing.T) {
143143

144144
var files []string
145145
for _, pattern := range []string{
146-
filepath.Join("fixtures", "validation", "*.json"),
147-
filepath.Join("fixtures", "validation", "*.yaml"),
148-
filepath.Join("fixtures", "bugs", "*", "*.json"),
149-
filepath.Join("fixtures", "bugs", "*", "*.yaml"),
150-
filepath.Join("fixtures", "go-swagger", "*", "*", "*.json"),
151-
filepath.Join("fixtures", "go-swagger", "*", "*", "*.yaml"),
152-
filepath.Join("fixtures", "petstore", "*.json"),
146+
filepath.Join("testdata", "validation", "*.json"),
147+
filepath.Join("testdata", "validation", "*.yaml"),
148+
filepath.Join("testdata", "bugs", "*", "*.json"),
149+
filepath.Join("testdata", "bugs", "*", "*.yaml"),
150+
filepath.Join("testdata", "go-swagger", "*", "*", "*.json"),
151+
filepath.Join("testdata", "go-swagger", "*", "*", "*.yaml"),
152+
filepath.Join("testdata", "petstore", "*.json"),
153153
} {
154154
matched, err := filepath.Glob(pattern)
155155
require.NoError(t, err)

‎pools_leak_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestPools_NoLeakOnSpecValidation(t *testing.T) {
2828
pools.ResetTracking()
2929
t.Cleanup(pools.ResetTracking)
3030

31-
fp := filepath.Join("fixtures", "bugs", "2866", "2866.yaml")
31+
fp := filepath.Join("testdata", "bugs", "2866", "2866.yaml")
3232
doc, err := loads.Spec(fp)
3333
require.NoError(t, err)
3434
require.NotNil(t, doc)

0 commit comments

Comments
 (0)
⌂ 换网址