From d885cd53f8dd71129e783c4d810737decfa026f0 Mon Sep 17 00:00:00 2001 From: repjarms Date: Tue, 18 Aug 2020 11:46:05 -0400 Subject: [PATCH] build(carthage): use latest swift sdk core --- Cartfile.resolved | 2 +- .../Tests/DiscoveryV2CPDTests.swift | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 Source/DiscoveryV2/Tests/DiscoveryV2CPDTests.swift diff --git a/Cartfile.resolved b/Cartfile.resolved index f8262c30f..9e067c263 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "IBM/swift-sdk-core" "1.0.0" +github "IBM/swift-sdk-core" "1.1.0" github "daltoniam/Starscream" "3.0.5" diff --git a/Source/DiscoveryV2/Tests/DiscoveryV2CPDTests.swift b/Source/DiscoveryV2/Tests/DiscoveryV2CPDTests.swift new file mode 100644 index 000000000..a3c8b54f2 --- /dev/null +++ b/Source/DiscoveryV2/Tests/DiscoveryV2CPDTests.swift @@ -0,0 +1,51 @@ + + +import XCTest +import Foundation +// Do not import @testable to ensure only public interface is exposed +import DiscoveryV2 + +class DiscoveryCPDTests: XCTestCase { + private var discovery: Discovery! + private var projectID: String! + private var collectionID: String! + private let timeout: TimeInterval = 30.0 + + // MARK: - Test Configuration + + override func setUp() { + super.setUp() + continueAfterFailure = false + instantiateDiscovery() + } + + func instantiateDiscovery() { + let authenticator = WatsonCloudPakForDataAuthenticator(username: WatsonCredentials.DiscoveryV2CPDUsername, password: WatsonCredentials.DiscoveryV2CPDPassword, url: WatsonCredentials.DiscoveryV2CPDURL) + + authenticator.disableSSLVerification() + + discovery = Discovery(version: "2020-08-12", authenticator: authenticator) + + // discovery.serviceURL = WatsonCredentials.DiscoveryV2CPDServiceURL + discovery.serviceURL = "http://localhost:9009" + + discovery.defaultHeaders["X-Watson-Learning-Opt-Out"] = "true" + discovery.defaultHeaders["X-Watson-Test"] = "true" + + discovery.disableSSLVerification() + + projectID = WatsonCredentials.DiscoveryV2CPDTestProjectID + collectionID = WatsonCredentials.DiscoveryV2CPDTestCollectionID + } + + func loadDocument(name: String, ext: String) -> Data? { + #if os(Linux) + let url = URL(fileURLWithPath: "Tests/DiscoveryV2Tests/Resources/" + name + "." + ext) + #else + let bundle = Bundle(for: type(of: self)) + guard let url = bundle.url(forResource: name, withExtension: ext) else { return nil } + #endif + let data = try? Data(contentsOf: url) + return data + } +}