Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/backend/firestore/firestorebk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"os"
"reflect"
"strings"
"sync"
"testing"
"time"
"unsafe"
Expand Down Expand Up @@ -190,6 +191,7 @@ type mockFirestoreServer struct {
// in the future.
firestorepb.FirestoreServer

mu sync.RWMutex
reqs []proto.Message

// If set, Commit returns this error.
Expand All @@ -202,7 +204,10 @@ func (s *mockFirestoreServer) BatchWrite(ctx context.Context, req *firestorepb.B
return nil, fmt.Errorf("x-goog-api-client = %v, expected gl-go key", xg)
}

s.mu.Lock()
s.reqs = append(s.reqs, req)
s.mu.Unlock()

if s.commitErr != nil {
return nil, s.commitErr
}
Expand Down Expand Up @@ -312,12 +317,14 @@ func TestDeleteDocuments(t *testing.T) {
}

var committed int
mockFirestore.mu.RLock()
for _, req := range mockFirestore.reqs {
switch r := req.(type) {
case *firestorepb.BatchWriteRequest:
committed += len(r.Writes)
}
}
mockFirestore.mu.RUnlock()

require.Equal(t, tt.documents, committed)

Expand Down