Skip to content

Commit 16db9ba

Browse files
Make spec test only
1 parent 8b257f9 commit 16db9ba

File tree

4 files changed

+38
-41
lines changed

4 files changed

+38
-41
lines changed

packages/firestore/src/local/indexeddb_persistence.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ import {
6363
} from './lru_garbage_collector';
6464
import {
6565
Persistence,
66-
PersistenceAction,
6766
PersistenceTransaction,
6867
PersistenceTransactionMode,
6968
PRIMARY_LEASE_LOST_ERROR_MSG,
@@ -750,7 +749,7 @@ export class IndexedDbPersistence implements Persistence {
750749
}
751750

752751
runTransaction<T>(
753-
action: PersistenceAction,
752+
action: string,
754753
mode: PersistenceTransactionMode,
755754
transactionOperation: (
756755
transaction: PersistenceTransaction

packages/firestore/src/local/persistence.ts

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,35 +31,6 @@ export const PRIMARY_LEASE_LOST_ERROR_MSG =
3131
'The current tab is not in the required state to perform this operation. ' +
3232
'It might be necessary to refresh the browser tab.';
3333

34-
/**
35-
* The cumulative list of actions run against Persistence. This is used by the
36-
* Spec tests to fail specific types of actions.
37-
*/
38-
export type PersistenceAction =
39-
| 'Get next mutation batch'
40-
| 'read document'
41-
| 'Allocate target'
42-
| 'Release target'
43-
| 'Execute query'
44-
| 'Handle user change'
45-
| 'Locally write mutations'
46-
| 'Acknowledge batch'
47-
| 'Reject batch'
48-
| 'Get highest unacknowledged batch id'
49-
| 'Get last stream token'
50-
| 'Set last stream token'
51-
| 'Get last remote snapshot version'
52-
| 'Set last remote snapshot version'
53-
| 'Apply remote event'
54-
| 'notifyLocalViewChanges'
55-
| 'Remote document keys'
56-
| 'Collect garbage'
57-
| 'maybeGarbageCollectMultiClientState'
58-
| 'Lookup mutation documents'
59-
| 'Get target data'
60-
| 'Get new document changes'
61-
| 'Synchronize last document change read time';
62-
6334
/**
6435
* A base class representing a persistence transaction, encapsulating both the
6536
* transaction's sequence numbers as well as a list of onCommitted listeners.
@@ -278,7 +249,7 @@ export interface Persistence {
278249
* @return A promise that is resolved once the transaction completes.
279250
*/
280251
runTransaction<T>(
281-
action: PersistenceAction,
252+
action: string,
282253
mode: PersistenceTransactionMode,
283254
transactionOperation: (
284255
transaction: PersistenceTransaction

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
import {
2424
GarbageCollectionScheduler,
2525
Persistence,
26-
PersistenceAction,
2726
PersistenceTransaction,
2827
PersistenceTransactionMode
2928
} from '../../../src/local/persistence';
@@ -37,7 +36,7 @@ import {
3736
MemoryPersistence
3837
} from '../../../src/local/memory_persistence';
3938
import { LruParams } from '../../../src/local/lru_garbage_collector';
40-
import { SpecDatabaseFailures } from './spec_test_runner';
39+
import { PersistenceAction, SpecDatabaseFailures } from './spec_test_runner';
4140
import { Connection, Stream } from '../../../src/remote/connection';
4241
import { StreamBridge } from '../../../src/remote/stream_bridge';
4342
import * as api from '../../../src/protos/firestore_proto_api';
@@ -61,17 +60,17 @@ export class MockMemoryPersistence extends MemoryPersistence {
6160
injectFailures?: SpecDatabaseFailures;
6261

6362
runTransaction<T>(
64-
action: PersistenceAction,
63+
action: string,
6564
mode: PersistenceTransactionMode,
6665
transactionOperation: (
6766
transaction: PersistenceTransaction
6867
) => PersistencePromise<T>
6968
): Promise<T> {
7069
if (this.injectFailures) {
71-
if (this.injectFailures[action] === undefined) {
70+
if (this.injectFailures[action as PersistenceAction] === undefined) {
7271
throw fail('Failure mode not specified for action: ' + action);
7372
}
74-
if (this.injectFailures[action]) {
73+
if (this.injectFailures[action as PersistenceAction]) {
7574
return Promise.reject(
7675
new IndexedDbTransactionError(new Error('Simulated retryable error'))
7776
);
@@ -90,16 +89,16 @@ export class MockIndexedDbPersistence extends IndexedDbPersistence {
9089
injectFailures?: SpecDatabaseFailures;
9190

9291
runTransaction<T>(
93-
action: PersistenceAction,
92+
action: string,
9493
mode: PersistenceTransactionMode,
9594
transactionOperation: (
9695
transaction: PersistenceTransaction
9796
) => PersistencePromise<T>
9897
): Promise<T> {
9998
if (this.injectFailures) {
100-
if (this.injectFailures[action] === undefined) {
99+
if (this.injectFailures[action as PersistenceAction] === undefined) {
101100
throw fail('Failure mode not specified for action: ' + action);
102-
} else if (this.injectFailures[action]) {
101+
} else if (this.injectFailures[action as PersistenceAction]) {
103102
return Promise.reject(
104103
new IndexedDbTransactionError(new Error('Simulated retryable error'))
105104
);

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ import {
113113
SharedWriteTracker
114114
} from './spec_test_components';
115115
import { IndexedDbPersistence } from '../../../src/local/indexeddb_persistence';
116-
import { PersistenceAction } from '../../../src/local/persistence';
117116

118117
const ARBITRARY_SEQUENCE_NUMBER = 2;
119118

@@ -1184,6 +1183,35 @@ export interface SpecConfig {
11841183
maxConcurrentLimboResolutions?: number;
11851184
}
11861185

1186+
/**
1187+
* The cumulative list of actions run against Persistence. This is used by the
1188+
* Spec tests to fail specific types of actions.
1189+
*/
1190+
export type PersistenceAction =
1191+
| 'Get next mutation batch'
1192+
| 'read document'
1193+
| 'Allocate target'
1194+
| 'Release target'
1195+
| 'Execute query'
1196+
| 'Handle user change'
1197+
| 'Locally write mutations'
1198+
| 'Acknowledge batch'
1199+
| 'Reject batch'
1200+
| 'Get highest unacknowledged batch id'
1201+
| 'Get last stream token'
1202+
| 'Set last stream token'
1203+
| 'Get last remote snapshot version'
1204+
| 'Set last remote snapshot version'
1205+
| 'Apply remote event'
1206+
| 'notifyLocalViewChanges'
1207+
| 'Remote document keys'
1208+
| 'Collect garbage'
1209+
| 'maybeGarbageCollectMultiClientState'
1210+
| 'Lookup mutation documents'
1211+
| 'Get target data'
1212+
| 'Get new document changes'
1213+
| 'Synchronize last document change read time';
1214+
11871215
/** Specifies failure or success for a list of database actions. */
11881216
export type SpecDatabaseFailures = Partial<
11891217
{

0 commit comments

Comments
 (0)