Skip to content

Commit

Permalink
Fix duplicated test
Browse files Browse the repository at this point in the history
  • Loading branch information
blva committed Jul 28, 2023
1 parent c366964 commit 021623c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
1 change: 1 addition & 0 deletions BREAKING-CHANGES-EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ These examples are automatically generated from unit tests.
[decreasing minLength value of request parameter](checker/check-request-parameters-min-length-updated_test.go?plain=1#L34)
[decreasing minimum value of request parameter](checker/check-request-parameters-min-updated_test.go?plain=1#L33)
[decreasing minimum value of request property](checker/check-request-property-min-updated_test.go?plain=1#L34)
[decreasing request body maximum value](checker/check-request-property-max-updated_test.go?plain=1#L91)
[decreasing request property maximum value](checker/check-request-property-max-updated_test.go?plain=1#L11)
[deprecating an operation with sunset greater than min](checker/checker_not_breaking_test.go?plain=1#L199)
[increasing max length of request body](checker/check-request-property-max-length-updated_test.go?plain=1#L11)
Expand Down
2 changes: 1 addition & 1 deletion checker/check-request-property-max-updated.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func RequestPropertyMaxDecreasedCheck(diffReport *diff.Diff, operationsSources *
} else {
result = append(result, ApiChange{
Id: "request-body-max-increased",
Level: ERR,
Level: INFO,
Text: fmt.Sprintf(config.i18n("request-body-max-increased"), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Expand Down
36 changes: 33 additions & 3 deletions checker/check-request-property-max-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,47 @@ func TestRequestBodyMaxIncreasingCheck(t *testing.T) {
require.NoError(t, err)

max := float64(20)
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["name"].Value.Max = &max
newMax := float64(25)
s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &max
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &newMax

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)

errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxDecreasedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-property-max-increased",
Id: "request-body-max-increased",
Level: checker.INFO,
Text: "the 'name' request property's max was increased from '15.00' to '20.00'",
Text: "the request's body max was increased from '20.00' to '25.00'",
Operation: "POST",
Path: "/pets",
Source: "../data/checker/request_property_max_decreased_base.yaml",
OperationId: "addPet",
}, errs[0])
}

// CL: decreasing request body maximum value
func TestRequestBodyMaxDecreasedCheck(t *testing.T) {
s1, err := open("../data/checker/request_property_max_decreased_base.yaml")
require.NoError(t, err)
s2, err := open("../data/checker/request_property_max_decreased_base.yaml")
require.NoError(t, err)

max := float64(25)
newMax := float64(20)
s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &max
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &newMax

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)

errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxDecreasedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-body-max-decreased",
Level: checker.ERR,
Text: "the request's body max was decreased to '20.00'",
Operation: "POST",
Path: "/pets",
Source: "../data/checker/request_property_max_decreased_base.yaml",
Expand Down

0 comments on commit 021623c

Please sign in to comment.