Skip to content

Commit fbcfeef

Browse files
Move isPrimary assert to the spec test runner (#1080)
1 parent 2353677 commit fbcfeef

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

packages/firestore/test/unit/specs/spec_builder.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -862,11 +862,6 @@ export class SpecBuilder {
862862

863863
protected nextStep(): void {
864864
if (this.currentStep !== null) {
865-
if (this.config.numClients === 1) {
866-
// Always verify that we are the primary client if there is only one
867-
// client.
868-
this.expectPrimaryState(true);
869-
}
870865
this.steps.push(this.currentStep);
871866
this.currentStep = null;
872867
}

packages/firestore/test/unit/specs/spec_test_runner.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ abstract class TestRunner {
371371
private persistence: Persistence;
372372
private sharedClientState: SharedClientState;
373373
private useGarbageCollection: boolean;
374+
private numClients: number;
374375
private databaseInfo: DatabaseInfo;
375376

376377
protected user = User.UNAUTHENTICATED;
@@ -402,6 +403,7 @@ abstract class TestRunner {
402403
});
403404

404405
this.useGarbageCollection = config.useGarbageCollection;
406+
this.numClients = config.numClients;
405407

406408
this.expectedLimboDocs = [];
407409
this.expectedActiveTargets = {};
@@ -943,10 +945,7 @@ abstract class TestRunner {
943945
this.expectedActiveTargets = expectation.activeTargets!;
944946
}
945947
if ('isPrimary' in expectation) {
946-
expect(this.syncEngine.isPrimaryClient).to.eq(
947-
expectation.isPrimary!,
948-
'isPrimary'
949-
);
948+
expect(this.isPrimaryClient).to.eq(expectation.isPrimary!, 'isPrimary');
950949
}
951950
if ('userCallbacks' in expectation) {
952951
expect(this.acknowledgedDocs).to.have.members(
@@ -958,6 +957,10 @@ abstract class TestRunner {
958957
}
959958
}
960959

960+
if (this.numClients === 1) {
961+
expect(this.isPrimaryClient).to.eq(true, 'isPrimary');
962+
}
963+
961964
// Clients don't reset their limbo docs on shutdown, so any validation will
962965
// likely fail.
963966
if (this.started) {

0 commit comments

Comments
 (0)