diff --git a/Package.swift b/Package.swift index e683f4c..226b4a0 100644 --- a/Package.swift +++ b/Package.swift @@ -54,5 +54,14 @@ let package = Package( dependencies: ["FirebaseDataConnect"], path: "Tests/Unit" ), + .testTarget( + name: "FirebaseDataConnectIntegration", + dependencies: ["FirebaseDataConnect"], + path: "Tests/Integration", + exclude: ["Gen/KitchenSink/Package.swift"], + resources: [ + .copy("Resources/fdc-kitchensink"), + ] + ), ] ) diff --git a/Tests/Integration/KitchenSinkClient.swift b/Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkClient.swift similarity index 52% rename from Tests/Integration/KitchenSinkClient.swift rename to Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkClient.swift index c816f4a..6b29c67 100644 --- a/Tests/Integration/KitchenSinkClient.swift +++ b/Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkClient.swift @@ -1,21 +1,6 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - import FirebaseDataConnect import Foundation -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public extension DataConnect { static var kitchenSinkClient: KitchenSinkClient = { let dc = DataConnect.dataConnect(connectorConfig: KitchenSinkClient.connectorConfig) @@ -23,7 +8,6 @@ public extension DataConnect { }() } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public class KitchenSinkClient { var dataConnect: DataConnect diff --git a/Tests/Integration/KitchenSinkKeys.swift b/Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkKeys.swift similarity index 86% rename from Tests/Integration/KitchenSinkKeys.swift rename to Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkKeys.swift index 3630b13..f076130 100644 --- a/Tests/Integration/KitchenSinkKeys.swift +++ b/Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkKeys.swift @@ -1,17 +1,3 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - import Foundation import FirebaseDataConnect @@ -24,7 +10,6 @@ public struct LargeIntTypeKey { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension LargeIntTypeKey: Codable { public init(from decoder: any Decoder) throws { var container = try decoder.container(keyedBy: CodingKeys.self) @@ -65,7 +50,6 @@ public struct LocalDateTypeKey { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension LocalDateTypeKey: Codable { public init(from decoder: any Decoder) throws { var container = try decoder.container(keyedBy: CodingKeys.self) @@ -106,7 +90,6 @@ public struct ScalarBoundaryKey { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension ScalarBoundaryKey: Codable { public init(from decoder: any Decoder) throws { var container = try decoder.container(keyedBy: CodingKeys.self) @@ -147,7 +130,6 @@ public struct StandardScalarsKey { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension StandardScalarsKey: Codable { public init(from decoder: any Decoder) throws { var container = try decoder.container(keyedBy: CodingKeys.self) @@ -188,7 +170,6 @@ public struct TestAutoIdKey { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension TestAutoIdKey: Codable { public init(from decoder: any Decoder) throws { var container = try decoder.container(keyedBy: CodingKeys.self) @@ -229,7 +210,6 @@ public struct TestIdKey { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) extension TestIdKey: Codable { public init(from decoder: any Decoder) throws { var container = try decoder.container(keyedBy: CodingKeys.self) diff --git a/Tests/Integration/KitchenSinkOperations.swift b/Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkOperations.swift similarity index 94% rename from Tests/Integration/KitchenSinkOperations.swift rename to Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkOperations.swift index 7b9b349..1225789 100644 --- a/Tests/Integration/KitchenSinkOperations.swift +++ b/Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkOperations.swift @@ -1,23 +1,8 @@ -// Copyright 2024 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - import FirebaseDataConnect import Foundation // MARK: Connector Client Extension -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public extension KitchenSinkClient { func createTestIdMutationRef(id: UUID) -> MutationRef< CreateTestIdMutation.Data, @@ -212,7 +197,6 @@ public extension KitchenSinkClient { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public enum CreateTestIdMutation { public static let OperationName = "createTestId" @@ -252,7 +236,6 @@ public enum CreateTestIdMutation { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public enum CreateTestAutoIdMutation { public static let OperationName = "createTestAutoId" @@ -269,7 +252,6 @@ public enum CreateTestAutoIdMutation { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public enum CreateStandardScalarMutation { public static let OperationName = "createStandardScalar" @@ -351,7 +333,6 @@ public enum CreateStandardScalarMutation { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public enum CreateScalarBoundaryMutation { public static let OperationName = "createScalarBoundary" @@ -446,7 +427,6 @@ public enum CreateScalarBoundaryMutation { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public enum CreateLargeNumMutation { public static let OperationName = "createLargeNum" @@ -525,7 +505,6 @@ public enum CreateLargeNumMutation { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public enum CreateLocalDateMutation { public static let OperationName = "createLocalDate" @@ -581,7 +560,6 @@ public enum CreateLocalDateMutation { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public enum GetStandardScalarQuery { public static let OperationName = "GetStandardScalar" @@ -675,7 +653,6 @@ public enum GetStandardScalarQuery { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public enum GetScalarBoundaryQuery { public static let OperationName = "GetScalarBoundary" @@ -755,7 +732,6 @@ public enum GetScalarBoundaryQuery { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public enum GetLargeNumQuery { public static let OperationName = "GetLargeNum" @@ -825,7 +801,6 @@ public enum GetLargeNumQuery { } } -@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public enum GetLocalDateTypeQuery { public static let OperationName = "GetLocalDateType" diff --git a/Tests/Integration/IntegrationTestBase.swift b/Tests/Integration/IntegrationTestBase.swift new file mode 100644 index 0000000..30bbc0d --- /dev/null +++ b/Tests/Integration/IntegrationTestBase.swift @@ -0,0 +1,44 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import XCTest + +import FirebaseCore +@testable import FirebaseDataConnect +import Foundation + +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) +class IntegrationTestBase: XCTestCase { + static var defaultApp: FirebaseApp? + + static var options: FirebaseOptions = { + let options = FirebaseOptions(googleAppID: "0:0000000000000:ios:testAppId", + gcmSenderID: "00000000000000000-00000000000-000000000") + options.projectID = "fdc-test" + options.apiKey = "testDummyApiKey" + return options + }() + + var fakeConnectorConfigOne = ConnectorConfig( + serviceId: "dataconnect", + location: "us-central1", + connector: "kitchensink" + ) + + override class func setUp() { + FirebaseApp.configure(options: options) + defaultApp = FirebaseApp.app() + DataConnect.kitchenSinkClient.useEmulator(port: 3628) + } +} diff --git a/Tests/Integration/IntegrationTests.swift b/Tests/Integration/IntegrationTests.swift index 97c7541..3f55a4f 100644 --- a/Tests/Integration/IntegrationTests.swift +++ b/Tests/Integration/IntegrationTests.swift @@ -18,21 +18,7 @@ import FirebaseCore @testable import FirebaseDataConnect @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) -final class IntegrationTests: XCTestCase { - class func setupFirebaseApp() { - if FirebaseApp.app() == nil { - let options = FirebaseOptions(googleAppID: "0:0000000000000:ios:0000000000000000", - gcmSenderID: "00000000000000000-00000000000-000000000") - options.projectID = "fdc-test" - FirebaseApp.configure(options: options) - } - } - - override class func setUp() { - setupFirebaseApp() - DataConnect.kitchenSinkClient.useEmulator(port: 3628) - } - +final class IntegrationTests: IntegrationTestBase { override func setUp(completion: @escaping ((any Error)?) -> Void) { Task { do { diff --git a/Tests/Resources/fdc-kitchensink/.firebaserc b/Tests/Integration/Resources/fdc-kitchensink/.firebaserc similarity index 100% rename from Tests/Resources/fdc-kitchensink/.firebaserc rename to Tests/Integration/Resources/fdc-kitchensink/.firebaserc diff --git a/Tests/Resources/fdc-kitchensink/.gitignore b/Tests/Integration/Resources/fdc-kitchensink/.gitignore similarity index 100% rename from Tests/Resources/fdc-kitchensink/.gitignore rename to Tests/Integration/Resources/fdc-kitchensink/.gitignore diff --git a/Tests/Resources/fdc-kitchensink/.vscode/settings.json b/Tests/Integration/Resources/fdc-kitchensink/.vscode/settings.json similarity index 100% rename from Tests/Resources/fdc-kitchensink/.vscode/settings.json rename to Tests/Integration/Resources/fdc-kitchensink/.vscode/settings.json diff --git a/Tests/Resources/fdc-kitchensink/dataconnect/dataconnect.yaml b/Tests/Integration/Resources/fdc-kitchensink/dataconnect/dataconnect.yaml similarity index 100% rename from Tests/Resources/fdc-kitchensink/dataconnect/dataconnect.yaml rename to Tests/Integration/Resources/fdc-kitchensink/dataconnect/dataconnect.yaml diff --git a/Tests/Resources/fdc-kitchensink/dataconnect/default/connector.yaml b/Tests/Integration/Resources/fdc-kitchensink/dataconnect/default/connector.yaml similarity index 93% rename from Tests/Resources/fdc-kitchensink/dataconnect/default/connector.yaml rename to Tests/Integration/Resources/fdc-kitchensink/dataconnect/default/connector.yaml index c838f33..e210ca9 100644 --- a/Tests/Resources/fdc-kitchensink/dataconnect/default/connector.yaml +++ b/Tests/Integration/Resources/fdc-kitchensink/dataconnect/default/connector.yaml @@ -23,5 +23,5 @@ authMode: "PUBLIC" # In future, we can consider a Test only Swift build plugin to gen the files, to avoid this. generate: swiftSdk: - outputDir: "/Users/aashishp/Scratchpad/KitchenSinkSwiftGen" + outputDir: "../../../../Gen/" package: "KitchenSink" diff --git a/Tests/Resources/fdc-kitchensink/dataconnect/default/mutations.gql b/Tests/Integration/Resources/fdc-kitchensink/dataconnect/default/mutations.gql similarity index 100% rename from Tests/Resources/fdc-kitchensink/dataconnect/default/mutations.gql rename to Tests/Integration/Resources/fdc-kitchensink/dataconnect/default/mutations.gql diff --git a/Tests/Resources/fdc-kitchensink/dataconnect/default/queries.gql b/Tests/Integration/Resources/fdc-kitchensink/dataconnect/default/queries.gql similarity index 100% rename from Tests/Resources/fdc-kitchensink/dataconnect/default/queries.gql rename to Tests/Integration/Resources/fdc-kitchensink/dataconnect/default/queries.gql diff --git a/Tests/Resources/fdc-kitchensink/dataconnect/schema/schema.gql b/Tests/Integration/Resources/fdc-kitchensink/dataconnect/schema/schema.gql similarity index 100% rename from Tests/Resources/fdc-kitchensink/dataconnect/schema/schema.gql rename to Tests/Integration/Resources/fdc-kitchensink/dataconnect/schema/schema.gql diff --git a/Tests/Resources/fdc-kitchensink/firebase.json b/Tests/Integration/Resources/fdc-kitchensink/firebase.json similarity index 100% rename from Tests/Resources/fdc-kitchensink/firebase.json rename to Tests/Integration/Resources/fdc-kitchensink/firebase.json