Skip to content

Commit d1d1a89

Browse files
committed
Fix CI tests
1 parent ba94c32 commit d1d1a89

File tree

7 files changed

+34
-4
lines changed

7 files changed

+34
-4
lines changed

Firestore/Example/Firestore.xcodeproj/xcshareddata/xcschemes/Firestore_Example_iOS.xcscheme

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@
8989
ReferencedContainer = "container:Firestore.xcodeproj">
9090
</BuildableReference>
9191
</BuildableProductRunnable>
92+
<EnvironmentVariables>
93+
<EnvironmentVariable
94+
key = "PROJECT_ID"
95+
value = "firestore-sdk-nightly"
96+
isEnabled = "YES">
97+
</EnvironmentVariable>
98+
<EnvironmentVariable
99+
key = "TARGET_BACKEND"
100+
value = "nightly"
101+
isEnabled = "YES">
102+
</EnvironmentVariable>
103+
</EnvironmentVariables>
92104
</LaunchAction>
93105
<ProfileAction
94106
buildConfiguration = "Release"

Firestore/Example/Tests/Util/FSTIntegrationTestCase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ extern "C" {
5151
/** Returns the default Firestore database ID for testing. */
5252
+ (NSString *)databaseID;
5353

54+
+ (void)switchToEnterpriseMode;
55+
5456
+ (bool)isRunningAgainstEmulator;
5557

5658
/** Returns a FirestoreSettings configured to use either hexa or the emulator. */

Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686

8787
static NSString *defaultProjectId;
8888
static NSString *defaultDatabaseId = @"(default)";
89+
static NSString *enterpriseDatabaseId = @"enterprise";
8990
static FIRFirestoreSettings *defaultSettings;
9091

9192
static bool runningAgainstEmulator = false;
@@ -273,6 +274,10 @@ + (NSString *)databaseID {
273274
return defaultDatabaseId;
274275
}
275276

277+
+ (void)switchToEnterpriseMode {
278+
defaultDatabaseId = enterpriseDatabaseId;
279+
}
280+
276281
+ (bool)isRunningAgainstEmulator {
277282
// The only way to determine whether or not we're running against the emulator is to figure out
278283
// which testing environment we're using. Essentially `setUpDefaults` determines

Firestore/Swift/Source/SwiftAPI/Pipeline/PipelineSource.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,13 @@ public struct PipelineSource: @unchecked Sendable {
3737
}
3838

3939
public func documents(_ docs: [DocumentReference]) -> Pipeline {
40-
let paths = docs.map { $0.path }
40+
let paths = docs.map { $0.path.hasPrefix("/") ? $0.path : "/" + $0.path }
4141
return Pipeline(stages: [DocumentsSource(paths: paths)], db: db)
4242
}
4343

4444
public func documents(_ paths: [String]) -> Pipeline {
45-
return Pipeline(stages: [DocumentsSource(paths: paths)], db: db)
45+
let normalizedPaths = paths.map { $0.hasPrefix("/") ? $0 : "/" + $0 }
46+
return Pipeline(stages: [DocumentsSource(paths: normalizedPaths)], db: db)
4647
}
4748

4849
public func create(from query: Query) -> Pipeline {

Firestore/Swift/Tests/Integration/PipelineApiTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ import XCTest
1818
import FirebaseFirestore
1919

2020
final class PipelineTests: FSTIntegrationTestCase {
21+
override func setUp() {
22+
FSTIntegrationTestCase.switchToEnterpriseMode()
23+
super.setUp()
24+
}
25+
2126
func testCreatePipeline() async throws {
2227
let pipelineSource: PipelineSource = db.pipeline()
2328

Firestore/Swift/Tests/Integration/PipelineTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ private let bookDocs: [String: [String: Any]] = [
113113

114114
@available(iOS 13, tvOS 13, macOS 10.15, macCatalyst 13, watchOS 7, *)
115115
class PipelineIntegrationTests: FSTIntegrationTestCase {
116+
override func setUp() {
117+
FSTIntegrationTestCase.switchToEnterpriseMode()
118+
super.setUp()
119+
}
120+
116121
func testCount() async throws {
117122
try await firestore().collection("foo").document("bar").setData(["foo": "bar", "x": 42])
118123
let snapshot = try await firestore()

Firestore/core/src/api/stages.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ google_firestore_v1_Pipeline_Stage DocumentsSource::to_proto() const {
8989

9090
for (size_t i = 0; i < documents_.size(); ++i) {
9191
result.args[i].which_value_type =
92-
google_firestore_v1_Value_string_value_tag;
93-
result.args[i].string_value = nanopb::MakeBytesArray(documents_[i]);
92+
google_firestore_v1_Value_reference_value_tag;
93+
result.args[i].reference_value = nanopb::MakeBytesArray(documents_[i]);
9494
}
9595

9696
result.options_count = 0;

0 commit comments

Comments
 (0)