Skip to content

Commit

Permalink
Fixed one test case based on the operating system in order to generat…
Browse files Browse the repository at this point in the history
…e the exception "URI path component is empty". Also, attempted to make tests run and pass both in windows and linux by changing the file separator if the OS is Windows.
  • Loading branch information
onurd86 committed Oct 16, 2023
1 parent 34aead1 commit ee74e2f
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,13 @@ class OpenAPILocalURLIssueTest {
@Test
fun testRelativeFilePathExistingFile() {

// swagger test directory
val urlToTest = "file://./src/test/resources/swagger/openapi_pet.json"
// get the current directory
val urlToTest = if (hostOs.contains("win")) {
"file:/./src/test/resources/swagger/openapi_pet.json"
}
else {
"file://./src/test/resources/swagger/openapi_pet.json"
}

// since the file does not exist and URL is invalid, a valid swagger cannot be created
// but an SutException should be thrown
Expand Down Expand Up @@ -227,7 +232,12 @@ class OpenAPILocalURLIssueTest {
fun testInvalidSwagger() {

// get the current directory
val urlToTest = "file://$swaggerTestDirectory/invalid_swagger.json"
val urlToTest = if (hostOs.contains("win")) {
"file:/$swaggerTestDirectory/invalid_swagger.json"
}
else {
"file://$swaggerTestDirectory/invalid_swagger.json"
}

// create swagger
swagger = OpenApiAccess.getOpenAPIFromURL(urlToTest)
Expand All @@ -240,7 +250,12 @@ class OpenAPILocalURLIssueTest {
fun testInvalidJSON() {

// get the current directory
val urlToTest = "file://$swaggerTestDirectory/invalid_json.json"
val urlToTest = if (hostOs.contains("win")) {
"file:/$swaggerTestDirectory/invalid_json.json"
}
else {
"file://$swaggerTestDirectory/invalid_json.json"
}

// exception to throw
val exception = Assertions.assertThrows(
Expand Down

0 comments on commit ee74e2f

Please sign in to comment.