Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

func Benchmark_KubernetesSpec(b *testing.B) {
fp := filepath.Join("fixtures", "go-swagger", "canary", "kubernetes", "swagger.json")
fp := filepath.Join("testdata", "go-swagger", "canary", "kubernetes", "swagger.json")
doc, err := loads.Spec(fp)
require.NoError(b, err)
require.NotNil(b, doc)
Expand Down
4 changes: 2 additions & 2 deletions default_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
func TestDefault_ValidateDefaults(t *testing.T) {
tests := []string{
"parameter",
"parameter-required",

Check failure on line 48 in default_validator_test.go

View workflow job for this annotation

GitHub Actions / test / Lint

string `parameter-required` has 3 occurrences, make it a constant (goconst)
"parameter-ref",
"parameter-items",
"header",
Expand All @@ -62,13 +62,13 @@
"header-items-default-response",
"header-items-response",
"header-pattern",
"header-badpattern",

Check failure on line 65 in default_validator_test.go

View workflow job for this annotation

GitHub Actions / test / Lint

string `header-badpattern` has 3 occurrences, make it a constant (goconst)
"schema-items-allOf",
"response-ref",
}

for _, tt := range tests {
path := filepath.Join("fixtures", "validation", "default", "valid-default-value-"+tt+jsonExt)
path := filepath.Join("testdata", "validation", "default", "valid-default-value-"+tt+jsonExt)
if DebugTest {
t.Logf("Testing valid default values for: %s", path)
}
Expand All @@ -83,7 +83,7 @@
assert.SliceContainsT(t, warns, "limit in query has a default value and is required as parameter")
}

path = filepath.Join("fixtures", "validation", "default", "invalid-default-value-"+tt+jsonExt)
path = filepath.Join("testdata", "validation", "default", "invalid-default-value-"+tt+jsonExt)
if DebugTest {
t.Logf("Testing invalid default values for: %s", path)
}
Expand Down
6 changes: 3 additions & 3 deletions deterministic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ func TestDeterministic_FullReport(t *testing.T) {
const runs = 20

for _, fixture := range []string{
filepath.Join("fixtures", "validation", "fixture-1231.yaml"),
filepath.Join("fixtures", "validation", "fixture-additional-items-invalid-values.yaml"),
filepath.Join("fixtures", "validation", "fixture-342.yaml"),
filepath.Join("testdata", "validation", "fixture-1231.yaml"),
filepath.Join("testdata", "validation", "fixture-additional-items-invalid-values.yaml"),
filepath.Join("testdata", "validation", "fixture-342.yaml"),
} {
t.Run(filepath.Base(fixture), func(t *testing.T) {
t.Parallel()
Expand Down
12 changes: 6 additions & 6 deletions doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func ExampleSpec() {
// Example with high level spec validation call, without showing warnings

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

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

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

// Example with the bundled Petstore spec:
// Also works with URL, e.g. http://petstore.swagger.io/v2/swagger.json
path := "fixtures/go-swagger/canary/petstore/swagger.json"
path := "testdata/go-swagger/canary/petstore/swagger.json"
doc, err := loads.JSONSpec(path)
if err == nil {
validator := validate.NewSpecValidator(doc.Schema(), strfmt.Default)
Expand Down Expand Up @@ -191,8 +191,8 @@ func getSimpleSchema() *spec.Schema {
func Test_Issue102_Circular(t *testing.T) {
// assert that the issue is fixed in go-openapi/spec
for _, fixture := range []string{
filepath.Join("fixtures", "bugs", "102", "fixture-102.json"),
filepath.Join("fixtures", "bugs", "123-validate", "fixture-123.json"),
filepath.Join("testdata", "bugs", "102", "fixture-102.json"),
filepath.Join("testdata", "bugs", "123-validate", "fixture-123.json"),
} {
t.Run(fixture, func(t *testing.T) {
filebytes, err := os.ReadFile(fixture)
Expand Down
4 changes: 2 additions & 2 deletions example_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"response",
"response-ref",
"parameter",
"parameter-required",

Check failure on line 31 in example_validator_test.go

View workflow job for this annotation

GitHub Actions / test / Lint

string `parameter-required` has 3 occurrences, make it a constant (goconst)
"parameter-ref",
"parameter-items",
"header",
Expand All @@ -45,12 +45,12 @@
"header-items-default-response",
"header-items-response",
"header-pattern",
"header-badpattern",

Check failure on line 48 in example_validator_test.go

View workflow job for this annotation

GitHub Actions / test / Lint

string `header-badpattern` has 3 occurrences, make it a constant (goconst)
"schema-items-allOf",
}

for _, tt := range tests {
path := filepath.Join("fixtures", "validation", "example", "valid-example-"+tt+".json")
path := filepath.Join("testdata", "validation", "example", "valid-example-"+tt+".json")
if DebugTest {
t.Logf("Testing valid example values for: %s", path)
}
Expand All @@ -67,7 +67,7 @@
*/
debugTest(t, path, res)

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

if DebugTest {
t.Logf("Testing invalid example values for: %s", path)
Expand Down
2 changes: 1 addition & 1 deletion items_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
)

func init() {
petstoreFixture := filepath.Join("fixtures", "petstore", "swagger.json")
petstoreFixture := filepath.Join("testdata", "petstore", "swagger.json")
petstore, err := os.ReadFile(petstoreFixture)
if err != nil {
log.Fatalf("could not initialize fixture: %s: %v", petstoreFixture, err)
Expand Down Expand Up @@ -244,7 +244,7 @@
items = spec.NewItems().CollectionOf(strItems, "").WithMinItems(1).WithMaxItems(5).UniqueValues()
validator = newItemsValidator(newPathSegments(parent.Name), parent.In, items, parent, strfmt.Default, nil)

data = []string{"aa", "bbb", "ccc"}

Check failure on line 247 in items_validator_test.go

View workflow job for this annotation

GitHub Actions / test / Lint

string `aa` has 6 occurrences, make it a constant (goconst)
err = validator.Validate(1, data)
assert.TrueT(t, err.HasErrors())
require.NotEmpty(t, err.Errors)
Expand Down
6 changes: 3 additions & 3 deletions jsonschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
}

var (
jsonSchemaFixturesPath = filepath.Join("fixtures", "jsonschema_suite")
schemaFixturesPath = filepath.Join("fixtures", "schemas")
formatFixturesPath = filepath.Join("fixtures", "formats")
jsonSchemaFixturesPath = filepath.Join("testdata", "jsonschema_suite")
schemaFixturesPath = filepath.Join("testdata", "schemas")
formatFixturesPath = filepath.Join("testdata", "formats")
)

func enabled() []string {
Expand All @@ -44,14 +44,14 @@
"minLength",
"maxLength",
"pattern",
"type",

Check failure on line 47 in jsonschema_test.go

View workflow job for this annotation

GitHub Actions / test / Lint

string `type` has 4 occurrences, but such constant `jsonType` already exists (goconst)
"minimum",
"maximum",
"multipleOf",
"enum",
"default",
"dependencies",
"items",

Check failure on line 54 in jsonschema_test.go

View workflow job for this annotation

GitHub Actions / test / Lint

string `items` has 4 occurrences, but such constant `jsonItems` already exists (goconst)
"maxItems",
"maxProperties",
"minItems",
Expand Down
8 changes: 4 additions & 4 deletions messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ func testMessageQuality(t *testing.T, haltOnErrors bool, continueOnErrors bool)
// set SWAGGER_DEBUG_TEST=1 env to get a report of messages at the end of each test.
// expectedMessage{"", false, false},
//
// expected messages and warnings are configured in ./fixtures/validation/expected_messages.yaml
// expected messages and warnings are configured in ./testdata/validation/expected_messages.yaml
//
var errs int // error count

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

if err := filepath.Walk(filepath.Join("fixtures", "validation"), testWalkSpecs(t, tested, haltOnErrors, continueOnErrors)); err != nil {
if err := filepath.Walk(filepath.Join("testdata", "validation"), testWalkSpecs(t, tested, haltOnErrors, continueOnErrors)); err != nil {
t.Logf("%v", err)
errs++
}
Expand Down Expand Up @@ -433,6 +433,6 @@ func testIssue(t *testing.T, path string, expectedNumErrors, expectedNumWarnings
// Test unitary fixture for dev and bug fixing.
func Test_SingleFixture(t *testing.T) {
t.SkipNow()
path := filepath.Join("fixtures", "validation", "fixture-1231.yaml")
path := filepath.Join("testdata", "validation", "fixture-1231.yaml")
testIssue(t, path, -1, -1)
}
14 changes: 7 additions & 7 deletions pointer_resolution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ func TestPointerResolution_EveryFixture(t *testing.T) {

var files []string
for _, pattern := range []string{
filepath.Join("fixtures", "validation", "*.json"),
filepath.Join("fixtures", "validation", "*.yaml"),
filepath.Join("fixtures", "bugs", "*", "*.json"),
filepath.Join("fixtures", "bugs", "*", "*.yaml"),
filepath.Join("fixtures", "go-swagger", "*", "*", "*.json"),
filepath.Join("fixtures", "go-swagger", "*", "*", "*.yaml"),
filepath.Join("fixtures", "petstore", "*.json"),
filepath.Join("testdata", "validation", "*.json"),
filepath.Join("testdata", "validation", "*.yaml"),
filepath.Join("testdata", "bugs", "*", "*.json"),
filepath.Join("testdata", "bugs", "*", "*.yaml"),
filepath.Join("testdata", "go-swagger", "*", "*", "*.json"),
filepath.Join("testdata", "go-swagger", "*", "*", "*.yaml"),
filepath.Join("testdata", "petstore", "*.json"),
} {
matched, err := filepath.Glob(pattern)
require.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion pools_leak_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestPools_NoLeakOnSpecValidation(t *testing.T) {
pools.ResetTracking()
t.Cleanup(pools.ResetTracking)

fp := filepath.Join("fixtures", "bugs", "2866", "2866.yaml")
fp := filepath.Join("testdata", "bugs", "2866", "2866.yaml")
doc, err := loads.Spec(fp)
require.NoError(t, err)
require.NotNil(t, doc)
Expand Down
6 changes: 3 additions & 3 deletions pools_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func Test_ParallelPool(t *testing.T) {
// that target OS. Typically, a CI runner breaks with "ThreadSanitizer failed to allocate ..."
// Also -race in this context times out on macos. We need our validation on our platform only.

fixture1 := filepath.Join("fixtures", "bugs", "1429", "swagger.yaml")
fixture2 := filepath.Join("fixtures", "bugs", "2866", "2866.yaml")
fixture3 := filepath.Join("fixtures", "bugs", "43", "fixture-43.yaml")
fixture1 := filepath.Join("testdata", "bugs", "1429", "swagger.yaml")
fixture2 := filepath.Join("testdata", "bugs", "2866", "2866.yaml")
fixture3 := filepath.Join("testdata", "bugs", "43", "fixture-43.yaml")

t.Run("should validate in parallel", func(t *testing.T) {
for range 20 {
Expand Down
2 changes: 1 addition & 1 deletion post/defaulter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/go-openapi/validate"
)

var defaulterFixturesPath = filepath.Join("..", "fixtures", "defaulting")
var defaulterFixturesPath = filepath.Join("..", "testdata", "defaulting")

func TestDefaulter(t *testing.T) {
schema, err := defaulterFixture()
Expand Down
2 changes: 1 addition & 1 deletion post/prune_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
validate "github.com/go-openapi/validate"
)

var pruneFixturesPath = filepath.Join("..", "fixtures", "pruning")
var pruneFixturesPath = filepath.Join("..", "testdata", "pruning")

func TestPrune(t *testing.T) {
schema, err := pruningFixture()
Expand Down
Loading
Loading