Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/spm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
runs-on: ${{ matrix.os }}
env:
FIREBASE_MAIN: 1
DISABLE_INTEGRATION_TESTS: 1
steps:
- uses: actions/checkout@v4
- name: Xcode
Expand Down
18 changes: 18 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ let package = Package(
dependencies: ["FirebaseDataConnect"],
path: "Tests/Unit"
),
.testTarget(
name: "FirebaseDataConnectIntegration",
dependencies: ["FirebaseDataConnect"],
path: integrationTestPath(),
exclude: ["Gen/KitchenSink/Package.swift"],
resources: [
.copy("Resources/fdc-kitchensink"),
]
),
]
)

Expand All @@ -67,3 +76,12 @@ func firebaseDependency() -> Package.Dependency {

return .package(url: firebaseURL, exact: "11.3.0")
}

func integrationTestPath() -> String? {
// Set this env variable to disable integration tests being run as part of CI
if ProcessInfo.processInfo.environment["DISABLE_INTEGRATION_TESTS"] != nil {
return "Tests/NoIntegration"
} else {
return "Tests/Integration"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
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
Expand Up @@ -24,7 +24,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 +64,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 +104,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 +144,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 +184,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 +224,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
Expand Up @@ -17,7 +17,6 @@ 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 +211,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 +250,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 +266,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 +347,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 +441,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 +519,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 +574,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 +667,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 +746,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 +815,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
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"
17 changes: 17 additions & 0 deletions Tests/NoIntegration/Readme
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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.



This is an empty folder temporarily created till we enable Integration tests in git.
Loading