Skip to content

Commit 0ce207f

Browse files
authored
test(firestore): correct TestIntegration_WatchQuery (googleapis#13053)
The TestIntegration_WatchQuery test was failing because it did not correctly specify the OldDoc field in the expected DocumentChange objects for DocumentModified and DocumentRemoved events. This resulted in test failures. Fixes: googleapis#13030
1 parent 04ac2d2 commit 0ce207f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

firestore/integration_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,15 +2326,17 @@ func TestIntegration_WatchQuery(t *testing.T) {
23262326
h.mustCreate(doc2, imap{"e": int64(1)})
23272327

23282328
// Update the first doc. We should see the change. We won't see doc2.
2329+
oldWDS := wds
23292330
h.mustUpdate(doc1, []Update{{Path: "e", Value: int64(3)}})
23302331
wds = h.mustGet(doc1)
23312332
check("update",
23322333
[]*DocumentSnapshot{wds},
2333-
[]DocumentChange{{Kind: DocumentModified, Doc: wds, OldIndex: 0, NewIndex: 0}})
2334+
[]DocumentChange{{Kind: DocumentModified, Doc: wds, OldDoc: oldWDS, OldIndex: 0, NewIndex: 0}})
23342335

23352336
// Now update doc so that it is not in the query. We should see a snapshot with no docs.
2337+
oldWDS = wds
23362338
h.mustUpdate(doc1, []Update{{Path: "e", Value: int64(0)}})
2337-
check("update2", nil, []DocumentChange{{Kind: DocumentRemoved, Doc: wds, OldIndex: 0, NewIndex: -1}})
2339+
check("update2", nil, []DocumentChange{{Kind: DocumentRemoved, Doc: oldWDS, OldDoc: oldWDS, OldIndex: 0, NewIndex: -1}})
23382340

23392341
// Add two docs out of order. We should see them in order.
23402342
doc3 := coll.NewDoc()
@@ -2353,7 +2355,7 @@ func TestIntegration_WatchQuery(t *testing.T) {
23532355
[]DocumentChange{{Kind: DocumentAdded, Doc: wds4, OldIndex: -1, NewIndex: 0}})
23542356
// Delete a doc.
23552357
h.mustDelete(doc4)
2356-
check("after del", []*DocumentSnapshot{wds3}, []DocumentChange{{Kind: DocumentRemoved, Doc: wds4, OldIndex: 0, NewIndex: -1}})
2358+
check("after del", []*DocumentSnapshot{wds3}, []DocumentChange{{Kind: DocumentRemoved, Doc: wds4, OldDoc: wds4, OldIndex: 0, NewIndex: -1}})
23572359

23582360
t.Cleanup(func() {
23592361
deleteDocuments([]*DocumentRef{doc1, doc2, doc3})

0 commit comments

Comments
 (0)