-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1131 from znsio/recursive_backward_compatibility_…
…check Recursive backward compatibility check
- Loading branch information
Showing
4 changed files
with
116 additions
and
40 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: 49 additions & 0 deletions
49
application/src/test/kotlin/application/BackwardCompatibilityCheckCommandTest.kt
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,49 @@ | ||
package application | ||
|
||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.spyk | ||
import org.junit.jupiter.api.AfterAll | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.Assertions.* | ||
import org.junit.jupiter.api.Test | ||
import java.io.File | ||
|
||
class BackwardCompatibilityCheckCommandTest { | ||
|
||
@Test | ||
fun `filesReferringToChangedSchemaFiles returns empty set when input is empty`() { | ||
val command = BackwardCompatibilityCheckCommand(mockk()) | ||
val result = command.filesReferringToChangedSchemaFiles(emptySet()) | ||
assertTrue(result.isEmpty()) | ||
} | ||
|
||
@Test | ||
fun `filesReferringToChangedSchemaFiles returns empty set when no files refer to changed schema files`() { | ||
val command = spyk<BackwardCompatibilityCheckCommand>() | ||
every { command.allOpenApiSpecFiles() } returns listOf( | ||
File("file1.yaml").apply { writeText("content1") }, | ||
File("file2.yaml").apply { writeText("content2") } | ||
) | ||
val result = command.filesReferringToChangedSchemaFiles(setOf("file3.yaml")) | ||
assertTrue(result.isEmpty()) | ||
} | ||
|
||
@Test | ||
fun `filesReferringToChangedSchemaFiles returns set of files that refer to changed schema files`() { | ||
val command = spyk<BackwardCompatibilityCheckCommand>() | ||
every { command.allOpenApiSpecFiles() } returns listOf( | ||
File("file1.yaml").apply { writeText("file3.yaml") }, | ||
File("file2.yaml").apply { writeText("file4.yaml") } | ||
) | ||
val result = command.filesReferringToChangedSchemaFiles(setOf("file3.yaml")) | ||
assertEquals(setOf("file1.yaml"), result) | ||
} | ||
|
||
@AfterEach | ||
fun `cleanup files`() { | ||
listOf(File("file1.yaml"), File("file2.yaml")).forEach { | ||
it.delete() | ||
} | ||
} | ||
} |
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
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