Skip to content

Commit

Permalink
test: fix expected-actual parameters in require.Equal
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Nov 26, 2024
1 parent e230c13 commit f875e9f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions openapi2conv/issue187_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func TestIssue187(t *testing.T) {
spec3, err := json.Marshal(doc3)
require.NoError(t, err)
const expected = `{"components":{"schemas":{"model.ProductSearchAttributeRequest":{"properties":{"filterField":{"type":"string"},"filterKey":{"type":"string"},"type":{"type":"string"},"values":{"$ref":"#/components/schemas/model.ProductSearchAttributeValueRequest"}},"title":"model.ProductSearchAttributeRequest","type":"object"},"model.ProductSearchAttributeValueRequest":{"properties":{"imageUrl":{"type":"string"},"text":{"type":"string"}},"title":"model.ProductSearchAttributeValueRequest","type":"object"}}},"info":{"contact":{"email":"[email protected]","name":"Test"},"description":"Test Golang Application","title":"Test","version":"1.0"},"openapi":"3.0.3","paths":{"/me":{"get":{"operationId":"someTest","responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/model.ProductSearchAttributeRequest"}}},"description":"successful operation"}},"summary":"Some test","tags":["probe"]}}}}`
require.JSONEq(t, string(spec3), expected)
require.JSONEq(t, expected, string(spec3))

err = doc3.Validate(context.Background())
require.NoError(t, err)
Expand Down Expand Up @@ -163,7 +163,7 @@ paths:
"200":
description: description
`
require.YAMLEq(t, string(spec3), expected)
require.YAMLEq(t, expected, string(spec3))

err = doc3.Validate(context.Background())
require.NoError(t, err)
Expand All @@ -190,5 +190,5 @@ securityDefinitions:

doc2, err := FromV3(doc3)
require.NoError(t, err)
require.Equal(t, doc2.SecurityDefinitions["OAuth2Application"].Flow, "application")
require.Equal(t, "application", doc2.SecurityDefinitions["OAuth2Application"].Flow)
}
2 changes: 1 addition & 1 deletion openapi3/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestEncodingSerializationMethod(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
got := tc.enc.SerializationMethod()
require.EqualValues(t, got, tc.want, "got %#v, want %#v", got, tc.want)
require.EqualValues(t, tc.want, got, "got %#v, want %#v", got, tc.want)
})
}
}
4 changes: 2 additions & 2 deletions openapi3/issue652_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestIssue652(t *testing.T) {
require.Contains(t, spec.Components.Schemas, schemaName)

schema := spec.Components.Schemas[schemaName]
assert.Equal(t, schema.Ref, "../definitions.yml#/components/schemas/TestSchema")
assert.Equal(t, schema.Value.Type, &openapi3.Types{"string"})
assert.Equal(t, "../definitions.yml#/components/schemas/TestSchema", schema.Ref)
assert.Equal(t, &openapi3.Types{"string"}, schema.Value.Type)
})
}
4 changes: 2 additions & 2 deletions openapi3/loader_relative_refs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ func TestLoadSpecWithRelativeDocumentRefs2(t *testing.T) {
require.Equal(t, "example request", nestedDirPath.Patch.RequestBody.Value.Description)

// check response schema and example
require.Equal(t, nestedDirPath.Patch.Responses.Value("200").Value.Content["application/json"].Schema.Value.Type, &Types{"string"})
require.Equal(t, &Types{"string"}, nestedDirPath.Patch.Responses.Value("200").Value.Content["application/json"].Schema.Value.Type)
expectedExample := "hello"
require.Equal(t, expectedExample, nestedDirPath.Patch.Responses.Value("200").Value.Content["application/json"].Examples["CustomTestExample"].Value.Value)

Expand All @@ -948,5 +948,5 @@ func TestLoadSpecWithRelativeDocumentRefs2(t *testing.T) {

// check response schema and example
require.Equal(t, &Types{"string"}, moreNestedDirPath.Patch.Responses.Value("200").Value.Content["application/json"].Schema.Value.Type)
require.Equal(t, moreNestedDirPath.Patch.Responses.Value("200").Value.Content["application/json"].Examples["CustomTestExample"].Value.Value, expectedExample)
require.Equal(t, expectedExample, moreNestedDirPath.Patch.Responses.Value("200").Value.Content["application/json"].Examples["CustomTestExample"].Value.Value)
}
2 changes: 1 addition & 1 deletion openapi3/response_issue224_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ func TestEmptyResponsesAreInvalid(t *testing.T) {
doc, err := loader.LoadFromData(spec)
require.NoError(t, err)

require.Equal(t, doc.ExternalDocs.Description, "See AsyncAPI example")
require.Equal(t, "See AsyncAPI example", doc.ExternalDocs.Description)

err = doc.Validate(context.Background())
require.EqualError(t, err, `invalid paths: invalid path /pet: invalid operation POST: the responses object MUST contain at least one response code`)
Expand Down
2 changes: 1 addition & 1 deletion openapi3filter/validate_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ components:
assert.NoError(t, err, "unable to read request body: %v", err)
assert.Equal(t, contentLen, bodySize, "expect ContentLength %d to equal body size %d", contentLen, bodySize)
bodyModified := originalBodySize != bodySize
assert.Equal(t, bodyModified, tc.expectedModification, "expect request body modification happened: %t, expected %t", bodyModified, tc.expectedModification)
assert.Equal(t, tc.expectedModification, bodyModified, "expect request body modification happened: %t, expected %t", bodyModified, tc.expectedModification)

validationInput.Request.Body, err = validationInput.Request.GetBody()
assert.NoError(t, err, "unable to re-generate body by GetBody(): %v", err)
Expand Down

0 comments on commit f875e9f

Please sign in to comment.