Skip to content

Commit

Permalink
add-check-descriptions-phase-5 (Tufin#425)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reuven Harrison authored Nov 13, 2023
1 parent c36bcf8 commit 98c4262
Show file tree
Hide file tree
Showing 52 changed files with 414 additions and 179 deletions.
6 changes: 3 additions & 3 deletions checker/check-api-tag-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestTagRemoved(t *testing.T) {
require.NotEmpty(t, errs)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "api-tag-removed",
Id: checker.APITagRemovedId,
Text: "api tag 'Test' removed",
Comment: "",
Level: checker.INFO,
Expand All @@ -75,9 +75,9 @@ func TestTagUpdated(t *testing.T) {
require.Len(t, errs, 2)
for cl := range errs {
require.Equal(t, checker.INFO, errs[cl].GetLevel())
if errs[cl].GetId() == "api-tag-removed" {
if errs[cl].GetId() == checker.APITagRemovedId {
require.Equal(t, checker.ApiChange{
Id: "api-tag-removed",
Id: checker.APITagRemovedId,
Text: "api tag 'Test' removed",
Comment: "",
Level: checker.INFO,
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-body-mediatype-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestRequestBodyMediaTypeAdded(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestBodyMediaTypeChangedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-body-media-type-added",
Id: checker.RequestBodyMediaTypeAddedId,
Text: "added the media type application/json to the request body",
Comment: "",
Level: checker.INFO,
Expand All @@ -43,7 +43,7 @@ func TestRequestBodyMediaTypeRemoved(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestBodyMediaTypeChangedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-body-media-type-removed",
Id: checker.RequestBodyMediaTypeRemovedId,
Text: "removed the media type application/json from the request body",
Comment: "",
Level: checker.ERR,
Expand Down
2 changes: 1 addition & 1 deletion checker/check-request-parameters-max-length-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func RequestParameterMaxLengthSetCheck(diffReport *diff.Diff, operationsSources
Id: RequestParameterMaxLengthSetId,
Level: WARN,
Text: config.Localize(RequestParameterMaxLengthSetId, ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxLengthDiff.To)),
Comment: config.Localize(RequestParameterMaxLengthSetId + "-comment"),
Comment: config.Localize(comment(RequestParameterMaxLengthSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down
2 changes: 1 addition & 1 deletion checker/check-request-parameters-max-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func RequestParameterMaxSetCheck(diffReport *diff.Diff, operationsSources *diff.
Id: RequestParameterMaxSetId,
Level: WARN,
Text: config.Localize(RequestParameterMaxSetId, ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxDiff.To)),
Comment: config.Localize(RequestParameterMaxSetId + "-comment"),
Comment: config.Localize(comment(RequestParameterMaxSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down
2 changes: 1 addition & 1 deletion checker/check-request-parameters-min-items-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func RequestParameterMinItemsSetCheck(diffReport *diff.Diff, operationsSources *
Id: RequestParameterMinItemsSetId,
Level: WARN,
Text: config.Localize(RequestParameterMinItemsSetId, ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minItemsDiff.To)),
Comment: config.Localize(RequestParameterMinItemsSetId + "-comment"),
Comment: config.Localize(comment(RequestParameterMinItemsSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down
2 changes: 1 addition & 1 deletion checker/check-request-parameters-min-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func RequestParameterMinSetCheck(diffReport *diff.Diff, operationsSources *diff.
Id: RequestParameterMinSetId,
Level: WARN,
Text: config.Localize(RequestParameterMinSetId, ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minDiff.To)),
Comment: config.Localize(RequestParameterMinSetId + "-comment"),
Comment: config.Localize(comment(RequestParameterMinSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-property-max-length-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func RequestPropertyMaxLengthSetCheck(diffReport *diff.Diff, operationsSources *
Id: RequestBodyMaxLengthSetId,
Level: WARN,
Text: config.Localize(RequestBodyMaxLengthSetId, ColorizedValue(maxLengthDiff.To)),
Comment: config.Localize(RequestBodyMaxLengthSetId + "-comment"),
Comment: config.Localize(comment(RequestBodyMaxLengthSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down Expand Up @@ -64,7 +64,7 @@ func RequestPropertyMaxLengthSetCheck(diffReport *diff.Diff, operationsSources *
Id: RequestPropertyMaxLengthSetId,
Level: WARN,
Text: config.Localize(RequestPropertyMaxLengthSetId, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.To)),
Comment: config.Localize(RequestPropertyMaxLengthSetId + "-comment"),
Comment: config.Localize(comment(RequestPropertyMaxLengthSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-property-max-length-updated.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func RequestPropertyMaxLengthUpdatedCheck(diffReport *diff.Diff, operationsSourc
result = append(result, ApiChange{
Id: RequestBodyMaxLengthDecreasedId,
Level: ERR,
Text: config.Localize("request-body-max-length-decreased", ColorizedValue(maxLengthDiff.To)),
Text: config.Localize(RequestBodyMaxLengthDecreasedId, ColorizedValue(maxLengthDiff.To)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand All @@ -48,7 +48,7 @@ func RequestPropertyMaxLengthUpdatedCheck(diffReport *diff.Diff, operationsSourc
result = append(result, ApiChange{
Id: RequestBodyMaxLengthIncreasedId,
Level: INFO,
Text: config.Localize("request-body-max-length-increased", ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)),
Text: config.Localize(RequestBodyMaxLengthIncreasedId, ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down
6 changes: 3 additions & 3 deletions checker/check-request-property-max-length-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestRequestBodyMaxLengthDecreasedCheck(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxLengthUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-body-max-length-increased",
Id: checker.RequestBodyMaxLengthIncreasedId,
Text: "the request's body maxLength was increased from '50' to '100'",
Level: checker.INFO,
Operation: "POST",
Expand Down Expand Up @@ -54,7 +54,7 @@ func TestRequestBodyMaxLengthIncreasedCheck(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxLengthUpdatedCheck), d, osm, checker.ERR)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-body-max-length-decreased",
Id: checker.RequestBodyMaxLengthDecreasedId,
Text: "the request's body maxLength was decreased to '50'",
Level: checker.ERR,
Operation: "POST",
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestRequestPropertyMaxLengthIncreasedCheck(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxLengthUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-property-max-length-increased",
Id: checker.RequestPropertyMaxLengthIncreasedId,
Text: "the 'description' request property's maxLength was increased from '50' to '100'",
Level: checker.INFO,
Operation: "POST",
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-property-max-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func RequestPropertyMaxSetCheck(diffReport *diff.Diff, operationsSources *diff.O
Id: RequestBodyMaxSetId,
Level: WARN,
Text: config.Localize(RequestBodyMaxSetId, ColorizedValue(maxDiff.To)),
Comment: config.Localize(RequestBodyMaxSetId + "-comment"),
Comment: config.Localize(comment(RequestBodyMaxSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down Expand Up @@ -64,7 +64,7 @@ func RequestPropertyMaxSetCheck(diffReport *diff.Diff, operationsSources *diff.O
Id: RequestPropertyMaxSetId,
Level: WARN,
Text: config.Localize(RequestPropertyMaxSetId, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.To)),
Comment: config.Localize(RequestPropertyMaxSetId + "-comment"),
Comment: config.Localize(comment(RequestPropertyMaxSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-property-max-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestRequestBodyMaxIncreasingCheck(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMaxDecreasedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-body-max-increased",
Id: checker.RequestBodyMaxIncreasedId,
Level: checker.INFO,
Text: "the request's body max was increased from '20.00' to '25.00'",
Operation: "POST",
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestRequestBodyMaxDecreasedCheck(t *testing.T) {
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",
Id: checker.RequestBodyMaxDecreasedId,
Level: checker.ERR,
Text: "the request's body max was decreased to '20.00'",
Operation: "POST",
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-property-min-items-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func RequestPropertyMinItemsSetCheck(diffReport *diff.Diff, operationsSources *d
Id: RequestBodyMinItemsSetId,
Level: WARN,
Text: config.Localize(RequestBodyMinItemsSetId, ColorizedValue(minItemsDiff.To)),
Comment: config.Localize(RequestBodyMinItemsSetId + "-comment"),
Comment: config.Localize(comment(RequestBodyMinItemsSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down Expand Up @@ -64,7 +64,7 @@ func RequestPropertyMinItemsSetCheck(diffReport *diff.Diff, operationsSources *d
Id: RequestPropertyMinItemsSetId,
Level: WARN,
Text: config.Localize(RequestPropertyMinItemsSetId, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minItemsDiff.To)),
Comment: config.Localize(RequestPropertyMinItemsSetId + "-comment"),
Comment: config.Localize(comment(RequestPropertyMinItemsSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down
8 changes: 4 additions & 4 deletions checker/check-request-property-min-length-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestRequestPropertyMinLengthDecreased(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinLengthUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-property-min-length-decreased",
Id: checker.RequestPropertyMinLengthDecreasedId,
Text: "the 'name' request property's minLength was decreased from '3' to '2'",
Comment: "",
Level: checker.INFO,
Expand All @@ -47,7 +47,7 @@ func TestRequestPropertyMinLengthIncreased(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinLengthUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-property-min-length-increased",
Id: checker.RequestPropertyMinLengthIncreasedId,
Text: "the 'name' request property's minLength was increased from '3' to '5'",
Comment: "",
Level: checker.ERR,
Expand All @@ -72,7 +72,7 @@ func TestRequestBodyMinLengthIncreased(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinLengthUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-body-min-length-increased",
Id: checker.RequestBodyMinLengthIncreasedId,
Text: "the request's body minLength was increased from '10' to '100'",
Comment: "",
Level: checker.ERR,
Expand All @@ -97,7 +97,7 @@ func TestRequestBodyMinLengthDecreased(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinLengthUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-body-min-length-decreased",
Id: checker.RequestBodyMinLengthDecreasedId,
Text: "the request's body minLength was decreased from '10' to '1'",
Comment: "",
Level: checker.INFO,
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-property-min-set.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func RequestPropertyMinSetCheck(diffReport *diff.Diff, operationsSources *diff.O
Id: RequestBodyMinSetId,
Level: WARN,
Text: config.Localize(RequestBodyMinSetId, ColorizedValue(minDiff.To)),
Comment: config.Localize(RequestBodyMinSetId + "-comment"),
Comment: config.Localize(comment(RequestBodyMinSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down Expand Up @@ -64,7 +64,7 @@ func RequestPropertyMinSetCheck(diffReport *diff.Diff, operationsSources *diff.O
Id: RequestPropertyMinSetId,
Level: WARN,
Text: config.Localize(RequestPropertyMinSetId, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.To)),
Comment: config.Localize(RequestPropertyMinSetId + "-comment"),
Comment: config.Localize(comment(RequestPropertyMinSetId)),
Operation: operation,
OperationId: operationItem.Revision.OperationID,
Path: path,
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-property-min-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestRequestPropertyMinIncreasedCheck(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinIncreasedCheck), d, osm, checker.ERR)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-property-min-increased",
Id: checker.RequestPropertyMinIncreasedId,
Text: "the 'age' request property's min was increased to '15.00'",
Level: checker.ERR,
Operation: "POST",
Expand All @@ -44,7 +44,7 @@ func TestRequestPropertyMinDecreasedCheck(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyMinIncreasedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-property-min-decreased",
Id: checker.RequestPropertyMinDecreasedId,
Text: "the 'age' request property's min was decreased from '15.00' to '10.00'",
Level: checker.INFO,
Operation: "POST",
Expand Down
6 changes: 3 additions & 3 deletions checker/check-request-property-one-of-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestRequestPropertyOneOfAdded(t *testing.T) {
OperationId: "updatePets",
},
{
Id: "request-property-one-of-added",
Id: checker.RequestPropertyOneOfAddedId,
Text: "added 'Breed3' to the '/oneOf[#/components/schemas/Dog]/breed' request property 'oneOf' list",
Comment: "",
Level: checker.INFO,
Expand All @@ -59,7 +59,7 @@ func TestRequestPropertyOneOfRemoved(t *testing.T) {

require.ElementsMatch(t, []checker.ApiChange{
{
Id: "request-body-one-of-removed",
Id: checker.RequestBodyOneOfRemovedId,
Text: "removed 'Rabbit' from the request body 'oneOf' list",
Comment: "",
Level: checker.ERR,
Expand All @@ -69,7 +69,7 @@ func TestRequestPropertyOneOfRemoved(t *testing.T) {
OperationId: "updatePets",
},
{
Id: "request-property-one-of-removed",
Id: checker.RequestPropertyOneOfRemovedId,
Text: "removed 'Breed3' from the '/oneOf[#/components/schemas/Dog]/breed' request property 'oneOf' list",
Comment: "",
Level: checker.ERR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestRequestPropertyPatternChanged(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyPatternUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-property-pattern-changed",
Id: checker.RequestPropertyPatternChangedId,
Text: "changed the pattern of the request property 'name' from '^\\w+$' to '^[\\w\\s]+$'",
Level: checker.WARN,
Operation: "POST",
Expand All @@ -45,7 +45,7 @@ func TestRequestPropertyPatternAdded(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyPatternUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-property-pattern-added",
Id: checker.RequestPropertyPatternAddedId,
Text: "added the pattern '^\\w+$' to the request property 'name'",
Level: checker.WARN,
Operation: "POST",
Expand All @@ -68,7 +68,7 @@ func TestRequestPropertyPatternRemoved(t *testing.T) {
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestPropertyPatternUpdatedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
Id: "request-property-pattern-removed",
Id: checker.RequestPropertyPatternRemovedId,
Text: "removed the pattern '^\\w+$' from the request property 'name'",
Level: checker.INFO,
Operation: "POST",
Expand Down
Loading

0 comments on commit 98c4262

Please sign in to comment.