Skip to content

Commit fe1bad6

Browse files
Integration Test Target Setup
1 parent ebf8538 commit fe1bad6

File tree

15 files changed

+55
-77
lines changed

15 files changed

+55
-77
lines changed

Package.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,14 @@ let package = Package(
5454
dependencies: ["FirebaseDataConnect"],
5555
path: "Tests/Unit"
5656
),
57+
.testTarget(
58+
name: "FirebaseDataConnectIntegration",
59+
dependencies: ["FirebaseDataConnect"],
60+
path: "Tests/Integration",
61+
exclude: ["Gen/KitchenSink/Package.swift"],
62+
resources: [
63+
.copy("Resources/fdc-kitchensink"),
64+
]
65+
),
5766
]
5867
)

Tests/Integration/KitchenSinkClient.swift renamed to Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkClient.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
1-
// Copyright 2024 Google LLC
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
14-
151
import FirebaseDataConnect
162
import Foundation
173

18-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
194
public extension DataConnect {
205
static var kitchenSinkClient: KitchenSinkClient = {
216
let dc = DataConnect.dataConnect(connectorConfig: KitchenSinkClient.connectorConfig)
227
return KitchenSinkClient(dataConnect: dc)
238
}()
249
}
2510

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

Tests/Integration/KitchenSinkKeys.swift renamed to Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkKeys.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
// Copyright 2024 Google LLC
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
14-
151
import Foundation
162

173
import FirebaseDataConnect
@@ -24,7 +10,6 @@ public struct LargeIntTypeKey {
2410
}
2511
}
2612

27-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
2813
extension LargeIntTypeKey: Codable {
2914
public init(from decoder: any Decoder) throws {
3015
var container = try decoder.container(keyedBy: CodingKeys.self)
@@ -65,7 +50,6 @@ public struct LocalDateTypeKey {
6550
}
6651
}
6752

68-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
6953
extension LocalDateTypeKey: Codable {
7054
public init(from decoder: any Decoder) throws {
7155
var container = try decoder.container(keyedBy: CodingKeys.self)
@@ -106,7 +90,6 @@ public struct ScalarBoundaryKey {
10690
}
10791
}
10892

109-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
11093
extension ScalarBoundaryKey: Codable {
11194
public init(from decoder: any Decoder) throws {
11295
var container = try decoder.container(keyedBy: CodingKeys.self)
@@ -147,7 +130,6 @@ public struct StandardScalarsKey {
147130
}
148131
}
149132

150-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
151133
extension StandardScalarsKey: Codable {
152134
public init(from decoder: any Decoder) throws {
153135
var container = try decoder.container(keyedBy: CodingKeys.self)
@@ -188,7 +170,6 @@ public struct TestAutoIdKey {
188170
}
189171
}
190172

191-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
192173
extension TestAutoIdKey: Codable {
193174
public init(from decoder: any Decoder) throws {
194175
var container = try decoder.container(keyedBy: CodingKeys.self)
@@ -229,7 +210,6 @@ public struct TestIdKey {
229210
}
230211
}
231212

232-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
233213
extension TestIdKey: Codable {
234214
public init(from decoder: any Decoder) throws {
235215
var container = try decoder.container(keyedBy: CodingKeys.self)

Tests/Integration/KitchenSinkOperations.swift renamed to Tests/Integration/Gen/KitchenSink/Sources/KitchenSinkOperations.swift

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,8 @@
1-
// Copyright 2024 Google LLC
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
14-
151
import FirebaseDataConnect
162
import Foundation
173

184
// MARK: Connector Client Extension
195

20-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
216
public extension KitchenSinkClient {
227
func createTestIdMutationRef(id: UUID) -> MutationRef<
238
CreateTestIdMutation.Data,
@@ -212,7 +197,6 @@ public extension KitchenSinkClient {
212197
}
213198
}
214199

215-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
216200
public enum CreateTestIdMutation {
217201
public static let OperationName = "createTestId"
218202

@@ -252,7 +236,6 @@ public enum CreateTestIdMutation {
252236
}
253237
}
254238

255-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
256239
public enum CreateTestAutoIdMutation {
257240
public static let OperationName = "createTestAutoId"
258241

@@ -269,7 +252,6 @@ public enum CreateTestAutoIdMutation {
269252
}
270253
}
271254

272-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
273255
public enum CreateStandardScalarMutation {
274256
public static let OperationName = "createStandardScalar"
275257

@@ -351,7 +333,6 @@ public enum CreateStandardScalarMutation {
351333
}
352334
}
353335

354-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
355336
public enum CreateScalarBoundaryMutation {
356337
public static let OperationName = "createScalarBoundary"
357338

@@ -446,7 +427,6 @@ public enum CreateScalarBoundaryMutation {
446427
}
447428
}
448429

449-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
450430
public enum CreateLargeNumMutation {
451431
public static let OperationName = "createLargeNum"
452432

@@ -525,7 +505,6 @@ public enum CreateLargeNumMutation {
525505
}
526506
}
527507

528-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
529508
public enum CreateLocalDateMutation {
530509
public static let OperationName = "createLocalDate"
531510

@@ -581,7 +560,6 @@ public enum CreateLocalDateMutation {
581560
}
582561
}
583562

584-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
585563
public enum GetStandardScalarQuery {
586564
public static let OperationName = "GetStandardScalar"
587565

@@ -675,7 +653,6 @@ public enum GetStandardScalarQuery {
675653
}
676654
}
677655

678-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
679656
public enum GetScalarBoundaryQuery {
680657
public static let OperationName = "GetScalarBoundary"
681658

@@ -755,7 +732,6 @@ public enum GetScalarBoundaryQuery {
755732
}
756733
}
757734

758-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
759735
public enum GetLargeNumQuery {
760736
public static let OperationName = "GetLargeNum"
761737

@@ -825,7 +801,6 @@ public enum GetLargeNumQuery {
825801
}
826802
}
827803

828-
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
829804
public enum GetLocalDateTypeQuery {
830805
public static let OperationName = "GetLocalDateType"
831806

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import XCTest
16+
17+
import FirebaseCore
18+
@testable import FirebaseDataConnect
19+
import Foundation
20+
21+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
22+
class IntegrationTestBase: XCTestCase {
23+
static var defaultApp: FirebaseApp?
24+
25+
static var options: FirebaseOptions = {
26+
let options = FirebaseOptions(googleAppID: "0:0000000000000:ios:testAppId",
27+
gcmSenderID: "00000000000000000-00000000000-000000000")
28+
options.projectID = "fdc-test"
29+
options.apiKey = "testDummyApiKey"
30+
return options
31+
}()
32+
33+
var fakeConnectorConfigOne = ConnectorConfig(
34+
serviceId: "dataconnect",
35+
location: "us-central1",
36+
connector: "kitchensink"
37+
)
38+
39+
override class func setUp() {
40+
FirebaseApp.configure(options: options)
41+
defaultApp = FirebaseApp.app()
42+
DataConnect.kitchenSinkClient.useEmulator(port: 3628)
43+
}
44+
}

Tests/Integration/IntegrationTests.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,7 @@ import FirebaseCore
1818
@testable import FirebaseDataConnect
1919

2020
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
21-
final class IntegrationTests: XCTestCase {
22-
class func setupFirebaseApp() {
23-
if FirebaseApp.app() == nil {
24-
let options = FirebaseOptions(googleAppID: "0:0000000000000:ios:0000000000000000",
25-
gcmSenderID: "00000000000000000-00000000000-000000000")
26-
options.projectID = "fdc-test"
27-
FirebaseApp.configure(options: options)
28-
}
29-
}
30-
31-
override class func setUp() {
32-
setupFirebaseApp()
33-
DataConnect.kitchenSinkClient.useEmulator(port: 3628)
34-
}
35-
21+
final class IntegrationTests: IntegrationTestBase {
3622
override func setUp(completion: @escaping ((any Error)?) -> Void) {
3723
Task {
3824
do {

0 commit comments

Comments
 (0)