Skip to content

Commit

Permalink
Merge pull request #135 from freetrade-io/fix-document-already-exists…
Browse files Browse the repository at this point in the history
…-error-message

Include the documents path in the already exists error message
  • Loading branch information
lukesmith authored Jun 29, 2022
2 parents 6614a51 + 2265fa5 commit 4824e1e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@freetrade-io/ts-firebase-driver-testing",
"version": "1.0.17",
"version": "1.0.18",
"description": "Swap out Firebase as a driver for in-process testing",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions src/driver/Firestore/InProcessFirestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ export class InProcessFirestoreDocRef implements IFirestoreDocRef {
if (existing.exists) {
throw new FirestoreError(
GRPCStatusCode.ALREADY_EXISTS,
`Document already exists: ${this.path}`,
`Document already exists: /documents/${this.path}`,
)
}
InProcessFirestoreDocRef.validateNoUndefinedFields(data)
Expand Down Expand Up @@ -1194,7 +1194,7 @@ class InProcessFirestoreWriteBatch implements IFirestoreWriteBatch {
if ((await documentRef.get()).exists) {
throw new FirestoreError(
GRPCStatusCode.ALREADY_EXISTS,
`Document already exists: ${documentRef.path}`,
`Document already exists: /documents/${documentRef.path}`,
)
}
return documentRef.set(data)
Expand Down Expand Up @@ -1300,7 +1300,7 @@ class InProcessFirestoreBulkWriter implements IFirestoreBulkWriter {
if ((await documentRef.get()).exists) {
throw new FirestoreError(
GRPCStatusCode.ALREADY_EXISTS,
`Document already exists: ${documentRef.path}`,
`Document already exists: /documents/${documentRef.path}`,
)
}
await documentRef.set(data)
Expand Down
2 changes: 1 addition & 1 deletion tests/driver/Firestore/InProcessFirestore.batch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe("In-process Firestore batched writes", () => {
// Then the write should fail;
expect(error).isFirestoreErrorWithCode(
GRPCStatusCode.ALREADY_EXISTS,
new RegExp("animals/tiger"),
new RegExp("/documents/animals/tiger"),
)

// And the document should not be changed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ describe("In-process Firestore BulkWriter", () => {
// Then the write should fail
expect(error).isFirestoreErrorWithCode(
GRPCStatusCode.ALREADY_EXISTS,
new RegExp("animals/tiger"),
new RegExp("/documents/animals/tiger"),
)

// And the document should not be changed.
Expand Down
2 changes: 1 addition & 1 deletion tests/driver/Firestore/InProcessFirestore.create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ describe("InProcessFirestore create", () => {
// Then the write should fail;
expect(error).isFirestoreErrorWithCode(
GRPCStatusCode.ALREADY_EXISTS,
new RegExp("animals/tiger"),
new RegExp("/documents/animals/tiger"),
)

// And the document should not be changed.
Expand Down

0 comments on commit 4824e1e

Please sign in to comment.