File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed
Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -127,11 +127,11 @@ type DBStats struct {
127127// CollStats represents the result of the [GetCollStats].
128128type CollStats struct {
129129 // Count is the number of documents in the collection.
130- Count int64 `bson:"count"`
130+ Count int64 `bson:"count,truncate "`
131131 // Size is the total size of the collection.
132- Size int64 `bson:"size"`
132+ Size int64 `bson:"size,truncate "`
133133 // AvgObjSize is the average size of documents in the collection.
134- AvgObjSize int64 `bson:"avgObjSize"`
134+ AvgObjSize int64 `bson:"avgObjSize,truncate "`
135135}
136136
137137// SayHello runs the db.hello() command and returns the [Hello].
Original file line number Diff line number Diff line change @@ -6,9 +6,33 @@ import (
66 "testing"
77 "time"
88
9+ "github.com/stretchr/testify/assert"
10+ "github.com/stretchr/testify/require"
11+ "go.mongodb.org/mongo-driver/v2/bson"
912 "go.mongodb.org/mongo-driver/v2/mongo"
1013)
1114
15+ func TestCollStats_DecodeFromFloat64 (t * testing.T ) {
16+ t .Parallel ()
17+
18+ input := bson.M {
19+ "count" : 0.0 ,
20+ "size" : 73179136.0 ,
21+ "avgObjSize" : 0.0 ,
22+ }
23+
24+ data , err := bson .Marshal (input )
25+ require .NoError (t , err )
26+
27+ var stats CollStats
28+ err = bson .Unmarshal (data , & stats )
29+ require .NoError (t , err )
30+
31+ assert .Equal (t , int64 (0 ), stats .Count )
32+ assert .Equal (t , int64 (73179136 ), stats .Size )
33+ assert .Equal (t , int64 (0 ), stats .AvgObjSize )
34+ }
35+
1236func TestRunWithRetry_NonTransientError (t * testing.T ) {
1337 t .Parallel ()
1438
You can’t perform that action at this time.
0 commit comments