-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve backward-compatibility testing (#546)
- Attempts to be exhaustive on backward-compatibility coverage to raise confidence that future refactors will not introduce unintended regressions. - Each incompatible condition is tested separately by comparing two spec files where the only difference is that fine-grained incompatible condition. - In some cases the current behavior appears incorrect. Tests are still added for these to avoid unintended regression, but are given TODO comments for later follow-up. - Pre-existing tests have been removed if they are redundant to avoid confusion and to follow the convention. Closes #545
- Loading branch information
Showing
142 changed files
with
5,407 additions
and
829 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
core/src/test/java/org/openapitools/openapidiff/core/BackwardCompatibilityTest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
core/src/test/java/org/openapitools/openapidiff/core/backcompat/ApiResponseBCTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.openapitools.openapidiff.core.backcompat; | ||
|
||
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiBackwardIncompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecChangedButCompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class ApiResponseBCTest { | ||
private final String BASE = "bc_response_apiresponse_base.yaml"; | ||
|
||
@Test | ||
public void unchanged() { | ||
assertSpecUnchanged(BASE, BASE); | ||
} | ||
|
||
@Test | ||
public void changedButCompatible() { | ||
assertSpecChangedButCompatible(BASE, "bc_response_apiresponse_changed_but_compatible.yaml"); | ||
} | ||
|
||
@Test | ||
public void decreased() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_response_apiresponse_decreased.yaml"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
core/src/test/java/org/openapitools/openapidiff/core/backcompat/ContentBCTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.openapitools.openapidiff.core.backcompat; | ||
|
||
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiBackwardIncompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecChangedButCompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class ContentBCTest { | ||
private final String BASE = "bc_content_base.yaml"; | ||
|
||
@Test | ||
public void unchanged() { | ||
assertSpecUnchanged(BASE, BASE); | ||
} | ||
|
||
@Test | ||
public void changedButCompatible() { | ||
assertSpecChangedButCompatible(BASE, "bc_content_changed_but_compatible.yaml"); | ||
} | ||
|
||
@Test | ||
public void requestDecreased() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_content_decreased.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseDecreased() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_response_content_decreased.yaml"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
core/src/test/java/org/openapitools/openapidiff/core/backcompat/EnumBCTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.openapitools.openapidiff.core.backcompat; | ||
|
||
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiBackwardIncompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecChangedButCompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class EnumBCTest { | ||
private final String BASE = "bc_enum_base.yaml"; | ||
|
||
@Test | ||
public void unchanged() { | ||
assertSpecUnchanged(BASE, BASE); | ||
} | ||
|
||
@Test | ||
public void changedButCompatible() { | ||
assertSpecChangedButCompatible(BASE, "bc_enum_changed_but_compatible.yaml"); | ||
} | ||
|
||
@Test | ||
public void requestDecreased() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_enum_decreased.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseIncreased() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_response_enum_increased.yaml"); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
core/src/test/java/org/openapitools/openapidiff/core/backcompat/HeaderBCTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package org.openapitools.openapidiff.core.backcompat; | ||
|
||
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiBackwardIncompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecChangedButCompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class HeaderBCTest { | ||
private final String BASE = "bc_response_header_base.yaml"; | ||
|
||
@Test | ||
public void responseHeaderUnchanged() { | ||
assertSpecUnchanged(BASE, BASE); | ||
} | ||
|
||
@Test | ||
public void responseHeaderDeprecated() { | ||
assertSpecChangedButCompatible(BASE, "bc_response_header_deprecated.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseHeaderRequiredAdded() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_response_header_required_added.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseHeaderRequiredDeleted() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_response_header_required_deleted.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseHeaderExplode() { | ||
String RESPONSE_HEADER_EXPLODE = "bc_response_header_explode.yaml"; | ||
assertOpenApiBackwardIncompatible(BASE, RESPONSE_HEADER_EXPLODE); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
core/src/test/java/org/openapitools/openapidiff/core/backcompat/HeadersBCTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.openapitools.openapidiff.core.backcompat; | ||
|
||
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiBackwardIncompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecChangedButCompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class HeadersBCTest { | ||
private final String BASE = "bc_response_headers_base.yaml"; | ||
|
||
@Test | ||
public void responseHeadersUnchanged() { | ||
assertSpecUnchanged(BASE, BASE); | ||
} | ||
|
||
@Test | ||
public void responseHeadersIncreased() { | ||
assertSpecChangedButCompatible(BASE, "bc_response_headers_increased.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseHeadersMissing() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_response_headers_missing.yaml"); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
core/src/test/java/org/openapitools/openapidiff/core/backcompat/MaxLengthBCTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package org.openapitools.openapidiff.core.backcompat; | ||
|
||
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiBackwardIncompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class MaxLengthBCTest { | ||
private final String BASE = "bc_maxlength_base.yaml"; | ||
|
||
@Test | ||
public void maxLengthUnchanged() { | ||
assertSpecUnchanged(BASE, BASE); | ||
} | ||
|
||
@Test | ||
public void requestMaxLengthDecreased() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_maxlength_decreased.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseMaxLengthIncreased() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_response_maxlength_increased.yaml"); | ||
} | ||
} |
114 changes: 114 additions & 0 deletions
114
core/src/test/java/org/openapitools/openapidiff/core/backcompat/NumericRangeBCTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package org.openapitools.openapidiff.core.backcompat; | ||
|
||
import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiBackwardIncompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecChangedButCompatible; | ||
import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class NumericRangeBCTest { | ||
private final String BASE = "bc_numericrange_base.yaml"; | ||
|
||
@Test | ||
public void unchanged() { | ||
assertSpecUnchanged(BASE, BASE); | ||
} | ||
|
||
@Test | ||
public void changedButCompatible() { | ||
// TODO: Fix bug where response range-narrowing is deemed incompatible, then test here | ||
assertSpecChangedButCompatible(BASE, "bc_numericrange_changed_but_compatible.yaml"); | ||
} | ||
|
||
@Test | ||
public void requestExclusiveMaxCreated() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_max_created.yaml"); | ||
} | ||
|
||
@Test | ||
public void requestExclusiveMaxSet() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_max_set.yaml"); | ||
} | ||
|
||
@Test | ||
public void requestExclusiveMinCreated() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_min_created.yaml"); | ||
} | ||
|
||
@Test | ||
public void requestExclusiveMinSet() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_exclusive_min_set.yaml"); | ||
} | ||
|
||
@Test | ||
public void requestMaxAdded() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_max_added.yaml"); | ||
} | ||
|
||
@Test | ||
public void requestMaxDecreased() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_max_decreased.yaml"); | ||
} | ||
|
||
@Test | ||
public void requestMinAdded() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_min_added.yaml"); | ||
} | ||
|
||
@Test | ||
public void requestMinIncreased() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_request_numericrange_min_increased.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseExclusiveMaxDeleted() { | ||
// TODO: Should be incompatible because clients may be unprepared for wider range | ||
// (test added to avoid unintentional regression) | ||
assertSpecChangedButCompatible(BASE, "bc_response_numericrange_exclusive_max_deleted.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseExclusiveMaxUnset() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_exclusive_max_unset.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseExclusiveMinDeleted() { | ||
// TODO: Should be incompatible because clients may be unprepared for wider range | ||
// (test added to avoid unintentional regression) | ||
assertSpecChangedButCompatible(BASE, "bc_response_numericrange_exclusive_min_deleted.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseExclusiveMinUnset() { | ||
assertOpenApiBackwardIncompatible(BASE, "bc_response_numericrange_exclusive_min_unset.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseMaxDeleted() { | ||
// TODO: Should be incompatible because clients may be unprepared for wider range | ||
// (test added to avoid unintentional regression) | ||
assertSpecChangedButCompatible(BASE, "bc_response_numericrange_max_deleted.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseMaxIncreased() { | ||
// TODO: Should be incompatible because clients may be unprepared | ||
// (test added to avoid unintentional regression) | ||
assertSpecChangedButCompatible(BASE, "bc_response_numericrange_max_increased.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseMinDecreased() { | ||
// TODO: Should be incompatible because clients may be unprepared for wider range | ||
// (test added to avoid unintentional regression) | ||
assertSpecChangedButCompatible(BASE, "bc_response_numericrange_min_decreased.yaml"); | ||
} | ||
|
||
@Test | ||
public void responseMinDeleted() { | ||
// TODO: Should be incompatible because clients may be unprepared for wider range | ||
// (test added to avoid unintentional regression) | ||
assertSpecChangedButCompatible(BASE, "bc_response_numericrange_min_deleted.yaml"); | ||
} | ||
} |
Oops, something went wrong.