Skip to content

Commit 793b28d

Browse files
authored
test: fix expected-actual parameters in require.Equal (#1035)
1 parent be48da5 commit 793b28d

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

openapi2conv/issue187_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func TestIssue187(t *testing.T) {
104104
spec3, err := json.Marshal(doc3)
105105
require.NoError(t, err)
106106
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"]}}}}`
107-
require.JSONEq(t, string(spec3), expected)
107+
require.JSONEq(t, expected, string(spec3))
108108

109109
err = doc3.Validate(context.Background())
110110
require.NoError(t, err)
@@ -163,7 +163,7 @@ paths:
163163
"200":
164164
description: description
165165
`
166-
require.YAMLEq(t, string(spec3), expected)
166+
require.YAMLEq(t, expected, string(spec3))
167167

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

191191
doc2, err := FromV3(doc3)
192192
require.NoError(t, err)
193-
require.Equal(t, doc2.SecurityDefinitions["OAuth2Application"].Flow, "application")
193+
require.Equal(t, "application", doc2.SecurityDefinitions["OAuth2Application"].Flow)
194194
}

openapi3/encoding_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func TestEncodingSerializationMethod(t *testing.T) {
9191
for _, tc := range testCases {
9292
t.Run(tc.name, func(t *testing.T) {
9393
got := tc.enc.SerializationMethod()
94-
require.EqualValues(t, got, tc.want, "got %#v, want %#v", got, tc.want)
94+
require.EqualValues(t, tc.want, got, "got %#v, want %#v", got, tc.want)
9595
})
9696
}
9797
}

openapi3/issue652_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func TestIssue652(t *testing.T) {
2323
require.Contains(t, spec.Components.Schemas, schemaName)
2424

2525
schema := spec.Components.Schemas[schemaName]
26-
assert.Equal(t, schema.Ref, "../definitions.yml#/components/schemas/TestSchema")
27-
assert.Equal(t, schema.Value.Type, &openapi3.Types{"string"})
26+
assert.Equal(t, "../definitions.yml#/components/schemas/TestSchema", schema.Ref)
27+
assert.Equal(t, &openapi3.Types{"string"}, schema.Value.Type)
2828
})
2929
}

openapi3/loader_relative_refs_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,7 @@ func TestLoadSpecWithRelativeDocumentRefs2(t *testing.T) {
927927
require.Equal(t, "example request", nestedDirPath.Patch.RequestBody.Value.Description)
928928

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

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

949949
// check response schema and example
950950
require.Equal(t, &Types{"string"}, moreNestedDirPath.Patch.Responses.Value("200").Value.Content["application/json"].Schema.Value.Type)
951-
require.Equal(t, moreNestedDirPath.Patch.Responses.Value("200").Value.Content["application/json"].Examples["CustomTestExample"].Value.Value, expectedExample)
951+
require.Equal(t, expectedExample, moreNestedDirPath.Patch.Responses.Value("200").Value.Content["application/json"].Examples["CustomTestExample"].Value.Value)
952952
}

openapi3/response_issue224_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ func TestEmptyResponsesAreInvalid(t *testing.T) {
458458
doc, err := loader.LoadFromData(spec)
459459
require.NoError(t, err)
460460

461-
require.Equal(t, doc.ExternalDocs.Description, "See AsyncAPI example")
461+
require.Equal(t, "See AsyncAPI example", doc.ExternalDocs.Description)
462462

463463
err = doc.Validate(context.Background())
464464
require.EqualError(t, err, `invalid paths: invalid path /pet: invalid operation POST: the responses object MUST contain at least one response code`)

openapi3filter/validate_request_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ components:
212212
assert.NoError(t, err, "unable to read request body: %v", err)
213213
assert.Equal(t, contentLen, bodySize, "expect ContentLength %d to equal body size %d", contentLen, bodySize)
214214
bodyModified := originalBodySize != bodySize
215-
assert.Equal(t, bodyModified, tc.expectedModification, "expect request body modification happened: %t, expected %t", bodyModified, tc.expectedModification)
215+
assert.Equal(t, tc.expectedModification, bodyModified, "expect request body modification happened: %t, expected %t", bodyModified, tc.expectedModification)
216216

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

0 commit comments

Comments
 (0)