Skip to content

Commit b04716e

Browse files
committed
fix tests running against linux by just grabbing spec files to test against and storing them in-repo
1 parent c72fad4 commit b04716e

12 files changed

Lines changed: 69096 additions & 24 deletions

Tests/OpenAPIKit30RealSpecSuite/GitHubAPITests.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,23 @@ final class GitHubAPICampatibilityTests: XCTestCase {
2727
commit for now.
2828
*/
2929
if githubAPI == nil {
30+
// Test file can be redownloaded from
31+
// https://raw.githubusercontent.com/github/rest-api-description/e4f28959fbc6c9fc4eea823b495061dded87e84d/descriptions/ghes-3.0/ghes-3.0.yaml
3032
githubAPI = Result {
31-
try YAMLDecoder().decode(
32-
OpenAPI.Document.self,
33-
from: String(contentsOf: URL(string: "https://raw.githubusercontent.com/github/rest-api-description/e4f28959fbc6c9fc4eea823b495061dded87e84d/descriptions/ghes-3.0/ghes-3.0.yaml")!)
33+
let currentWorkingDirectory = FileManager.default.currentDirectoryPath
34+
return try YAMLDecoder().decode(
35+
OpenAPI.Document.self,
36+
from: String(
37+
contentsOf: URL(
38+
filePath: "./Tests/inputs/ghes-3.0.yaml",
39+
relativeTo: URL(filePath: currentWorkingDirectory, directoryHint: .isDirectory)),
40+
encoding: .utf8)
3441
)
3542
}
3643
}
3744
}
3845

3946
func test_successfullyParsedDocument() throws {
40-
#if os(Linux)
41-
throw XCTSkip("Swift bug causes CI failure currently (line 48): failed - The operation could not be completed. The file doesn’t exist.")
42-
#endif
4347
switch githubAPI {
4448
case nil:
4549
XCTFail("Did not attempt to pull GitHub API documentation like expected.")

Tests/OpenAPIKit30RealSpecSuite/GoogleBooksAPITests.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,23 @@ final class GoogleBooksAPICampatibilityTests: XCTestCase {
2222

2323
override func setUp() {
2424
if booksAPI == nil {
25+
// Test file can be redownloaded from
26+
// https://raw.githubusercontent.com/APIs-guru/openapi-directory/master/APIs/googleapis.com/books/v1/openapi.yaml
2527
booksAPI = Result {
26-
try YAMLDecoder().decode(
27-
OpenAPI.Document.self,
28-
from: String(contentsOf: URL(string: "https://raw.githubusercontent.com/APIs-guru/openapi-directory/master/APIs/googleapis.com/books/v1/openapi.yaml")!)
28+
let currentWorkingDirectory = FileManager.default.currentDirectoryPath
29+
return try YAMLDecoder().decode(
30+
OpenAPI.Document.self,
31+
from: String(
32+
contentsOf: URL(
33+
filePath: "./Tests/inputs/google-books-3.0.yaml",
34+
relativeTo: URL(filePath: currentWorkingDirectory, directoryHint: .isDirectory)),
35+
encoding: .utf8)
2936
)
3037
}
3138
}
3239
}
3340

3441
func test_successfullyParsedDocument() throws {
35-
#if os(Linux)
36-
throw XCTSkip("Swift bug causes CI failure currently (line 48): failed - The operation could not be completed. The file doesn’t exist.")
37-
#endif
3842
switch booksAPI {
3943
case nil:
4044
XCTFail("Did not attempt to pull Google Books API documentation like expected.")

Tests/OpenAPIKit30RealSpecSuite/PetStoreAPITests.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,23 @@ final class PetStoreAPICampatibilityTests: XCTestCase {
2222

2323
override func setUp() {
2424
if petStoreAPI == nil {
25+
// Test file can be redownloaded from
26+
// https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml
2527
petStoreAPI = Result {
26-
try YAMLDecoder().decode(
27-
OpenAPI.Document.self,
28-
from: String(contentsOf: URL(string: "https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml")!)
28+
let currentWorkingDirectory = FileManager.default.currentDirectoryPath
29+
return try YAMLDecoder().decode(
30+
OpenAPI.Document.self,
31+
from: String(
32+
contentsOf: URL(
33+
filePath: "./Tests/inputs/pet-store-3.0.yaml",
34+
relativeTo: URL(filePath: currentWorkingDirectory, directoryHint: .isDirectory)),
35+
encoding: .utf8)
2936
)
3037
}
3138
}
3239
}
3340

3441
func test_successfullyParsedDocument() throws {
35-
#if os(Linux)
36-
throw XCTSkip("Swift bug causes CI failure currently (line 48): failed - The operation could not be completed. The file doesn’t exist.")
37-
#endif
3842
switch petStoreAPI {
3943
case nil:
4044
XCTFail("Did not attempt to pull Pet Store API documentation like expected.")

Tests/OpenAPIKit30RealSpecSuite/TomTomAPITests.swift

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,23 @@ final class TomTomAPICampatibilityTests: XCTestCase {
2222

2323
override func setUp() {
2424
if tomtomAPI == nil {
25+
// Test file can be redownloaded from
26+
// https://raw.githubusercontent.com/APIs-guru/openapi-directory/c9190db19e5cb151592d44f0d4482839e1e5a8e0/APIs/tomtom.com/search/1.0.0/openapi.yaml
2527
tomtomAPI = Result {
26-
try YAMLDecoder().decode(
27-
OpenAPI.Document.self,
28-
from: String(contentsOf: URL(string: "https://raw.githubusercontent.com/APIs-guru/openapi-directory/c9190db19e5cb151592d44f0d4482839e1e5a8e0/APIs/tomtom.com/search/1.0.0/openapi.yaml")!)
28+
let currentWorkingDirectory = FileManager.default.currentDirectoryPath
29+
return try YAMLDecoder().decode(
30+
OpenAPI.Document.self,
31+
from: String(
32+
contentsOf: URL(
33+
filePath: "./Tests/inputs/tomtom-3.0.yaml",
34+
relativeTo: URL(filePath: currentWorkingDirectory, directoryHint: .isDirectory)),
35+
encoding: .utf8)
2936
)
3037
}
3138
}
3239
}
3340

3441
func test_successfullyParsedDocument() throws {
35-
#if os(Linux)
36-
throw XCTSkip("Swift bug causes CI failure currently (line 43): failed - The operation could not be completed. The file doesn’t exist.")
37-
#endif
3842
switch tomtomAPI {
3943
case nil:
4044
XCTFail("Did not attempt to pull TomTom API documentation like expected.")

Tests/inputs/ghes-3.0-LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 GitHub
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)