diff --git a/Tests/miniGnomonTests/LoggingSpec.swift b/Tests/miniGnomonTests/LoggingSpec.swift deleted file mode 100644 index adc86f9..0000000 --- a/Tests/miniGnomonTests/LoggingSpec.swift +++ /dev/null @@ -1,112 +0,0 @@ -// -// Created by Vladimir Burdukov on 8/21/20. -// - -//import XCTest -//import Nimble -//import RxSwift -//import RxBlocking -// -//@testable import miniGnomon -// -//class LoggingSpec: XCTestCase { -// -// override func setUp() { -// super.setUp() -// -// Gnomon.logging = false -// Gnomon.log = { string in -// print(string) -// } -// } -// -// func request(global: Bool? = nil, request loggingPolicy: LoggingPolicy? = nil) { -// if let global = global { -// Gnomon.logging = global -// } -// -// do { -// let request = try Request(URLString: "https://example.com/") -// request.httpSessionDelegate = try TestResponses.jsonResponse(result: ["key": 123], cached: false) -// -// if let loggingPolicy = loggingPolicy { -// request.loggingPolicy = loggingPolicy -// } -// -// let result = Gnomon.models(for: request).toBlocking(timeout: BlockingTimeout).materialize() -// -// switch result { -// case let .completed(responses): -// expect(responses).to(haveCount(1)) -// -// let response = responses[0] -// expect(response.result.key) == 123 -// case let .failed(_, error): -// fail("\(error)") -// } -// } catch { -// fail("\(error)") -// } -// } -// -// func testDefaultState() { -// var log: String? = nil -// -// Gnomon.log = { string in -// log = log ?? "" + string + "\n" -// } -// -// request() -// expect(log).to(beNil()) -// } -// -// func testDisabledState() { -// Gnomon.logging = false -// testDefaultState() -// } -// -// func testEnabledLogging() { -// var log: String? = nil -// -// Gnomon.log = { string in -// log = log ?? "" + string + "\n" -// } -// -// request(global: true) -// expect(log) == "curl -X GET \"https://example.com/\"\n" -// } -// -// func testEnabledLoggingAndDisabledRequestLogging() { -// var log: String? = nil -// -// Gnomon.log = { string in -// log = log ?? "" + string + "\n" -// } -// -// request(global: true, request: .never) -// expect(log) == "curl -X GET \"https://example.com/\"\n" -// } -// -// func testDisabledLoggingAndEnabledRequestLogging() { -// var log: String? = nil -// -// Gnomon.log = { string in -// log = log ?? "" + string + "\n" -// } -// -// request(global: false, request: .always) -// expect(log).to(beNil()) -// } -// -// func testDisabledLoggingAndDisabledRequestLogging() { -// var log: String? = nil -// -// Gnomon.log = { string in -// log = log ?? "" + string + "\n" -// } -// -// request(global: false, request: .never) -// expect(log).to(beNil()) -// } -// -//} diff --git a/Tests/miniGnomonTests/RequestParamsSpec.swift b/Tests/miniGnomonTests/Request params/RequestParamsSpec.swift similarity index 82% rename from Tests/miniGnomonTests/RequestParamsSpec.swift rename to Tests/miniGnomonTests/Request params/RequestParamsSpec.swift index edec91e..4e8d08b 100644 --- a/Tests/miniGnomonTests/RequestParamsSpec.swift +++ b/Tests/miniGnomonTests/Request params/RequestParamsSpec.swift @@ -56,8 +56,9 @@ class ParamsSpec: XCTestCase { func testMultipartFormParams() throws { let form = ["question": "The Ultimate Question of Life, the Universe, and Everything", "answer": "42"] let expected = String(data: try Data( - contentsOf: URL(fileURLWithPath: #file).deletingLastPathComponent().appendingPathComponent("Fixtures") - .appendingPathComponent("multipart-simple").appendingPathExtension("txt") + contentsOf: URL(fileURLWithPath: #file) + .deletingLastPathComponent().deletingLastPathComponent() + .appendingPathComponent("Fixtures").appendingPathComponent("multipart-simple").appendingPathExtension("txt") ), encoding: .utf8)! for method in bodyMethods { @@ -76,14 +77,16 @@ class ParamsSpec: XCTestCase { func testMultipartFilesParams() throws { let data = try Data( - contentsOf: URL(fileURLWithPath: #file).deletingLastPathComponent().appendingPathComponent("Fixtures") - .appendingPathComponent("lorem-ipsum").appendingPathExtension("txt") + contentsOf: URL(fileURLWithPath: #file) + .deletingLastPathComponent().deletingLastPathComponent() + .appendingPathComponent("Fixtures").appendingPathComponent("lorem-ipsum").appendingPathExtension("txt") ) let file = MultipartFile(data: data, contentType: "text/plain", filename: "lorem-ipsum.txt") let expected = String(data: try Data( - contentsOf: URL(fileURLWithPath: #file).deletingLastPathComponent().appendingPathComponent("Fixtures") - .appendingPathComponent("multipart-file").appendingPathExtension("txt") + contentsOf: URL(fileURLWithPath: #file) + .deletingLastPathComponent().deletingLastPathComponent() + .appendingPathComponent("Fixtures").appendingPathComponent("multipart-file").appendingPathExtension("txt") ), encoding: .utf8)! for method in bodyMethods { @@ -105,14 +108,16 @@ class ParamsSpec: XCTestCase { func testMultipartMixedParams() throws { let form = ["question": "The Ultimate Question of Life, the Universe, and Everything"] let data = try Data( - contentsOf: URL(fileURLWithPath: #file).deletingLastPathComponent().appendingPathComponent("Fixtures") - .appendingPathComponent("lorem-ipsum").appendingPathExtension("txt") + contentsOf: URL(fileURLWithPath: #file) + .deletingLastPathComponent().deletingLastPathComponent() + .appendingPathComponent("Fixtures").appendingPathComponent("lorem-ipsum").appendingPathExtension("txt") ) let file = MultipartFile(data: data, contentType: "text/plain", filename: "lorem-ipsum.txt") let expected = String(data: try Data( - contentsOf: URL(fileURLWithPath: #file).deletingLastPathComponent().appendingPathComponent("Fixtures") - .appendingPathComponent("multipart-mixed").appendingPathExtension("txt") + contentsOf: URL(fileURLWithPath: #file) + .deletingLastPathComponent().deletingLastPathComponent() + .appendingPathComponent("Fixtures").appendingPathComponent("multipart-mixed").appendingPathExtension("txt") ), encoding: .utf8)! for method in bodyMethods { diff --git a/Tests/miniGnomonTests/URLParamsEncodingSpec.swift b/Tests/miniGnomonTests/Request params/URLParamsEncodingSpec.swift similarity index 100% rename from Tests/miniGnomonTests/URLParamsEncodingSpec.swift rename to Tests/miniGnomonTests/Request params/URLParamsEncodingSpec.swift diff --git a/Tests/miniGnomonTests/URLRequestGenerationSpec.swift b/Tests/miniGnomonTests/Request params/URLRequestGenerationSpec.swift similarity index 100% rename from Tests/miniGnomonTests/URLRequestGenerationSpec.swift rename to Tests/miniGnomonTests/Request params/URLRequestGenerationSpec.swift diff --git a/Tests/miniGnomonTests/XPathSpec.swift b/Tests/miniGnomonTests/Request params/XPathSpec.swift similarity index 100% rename from Tests/miniGnomonTests/XPathSpec.swift rename to Tests/miniGnomonTests/Request params/XPathSpec.swift diff --git a/Tests/miniGnomonTests/CacheSpec.swift b/Tests/miniGnomonTests/Requests/CacheSpec.swift similarity index 100% rename from Tests/miniGnomonTests/CacheSpec.swift rename to Tests/miniGnomonTests/Requests/CacheSpec.swift diff --git a/Tests/miniGnomonTests/CachedThenFetchSpec.swift b/Tests/miniGnomonTests/Requests/CachedThenFetchSpec.swift similarity index 100% rename from Tests/miniGnomonTests/CachedThenFetchSpec.swift rename to Tests/miniGnomonTests/Requests/CachedThenFetchSpec.swift diff --git a/Tests/miniGnomonTests/DecodableSpec.swift b/Tests/miniGnomonTests/Requests/DecodableSpec.swift similarity index 100% rename from Tests/miniGnomonTests/DecodableSpec.swift rename to Tests/miniGnomonTests/Requests/DecodableSpec.swift diff --git a/Tests/miniGnomonTests/MultipleRequestsSpec.swift b/Tests/miniGnomonTests/Requests/MultipleRequestsSpec.swift similarity index 100% rename from Tests/miniGnomonTests/MultipleRequestsSpec.swift rename to Tests/miniGnomonTests/Requests/MultipleRequestsSpec.swift diff --git a/Tests/miniGnomonTests/RequestSpec.swift b/Tests/miniGnomonTests/Requests/RequestSpec.swift similarity index 100% rename from Tests/miniGnomonTests/RequestSpec.swift rename to Tests/miniGnomonTests/Requests/RequestSpec.swift