Skip to content

Commit

Permalink
Integration Test Target Setup
Browse files Browse the repository at this point in the history
  • Loading branch information
aashishpatil-g committed Sep 19, 2024
1 parent ebf8538 commit fe1bad6
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 77 deletions.
9 changes: 9 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
]
),
]
)
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
// 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)
return KitchenSinkClient(dataConnect: dc)
}()
}

@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
public class KitchenSinkClient {
var dataConnect: DataConnect

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand All @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down
44 changes: 44 additions & 0 deletions Tests/Integration/IntegrationTestBase.swift
Original file line number Diff line number Diff line change
@@ -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)
}
}
16 changes: 1 addition & 15 deletions Tests/Integration/IntegrationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit fe1bad6

Please sign in to comment.