@@ -24,7 +24,7 @@ import (
2424
2525 "github.com/prometheus/client_golang/prometheus/testutil"
2626 "github.com/prometheus/common/promslog"
27- "github.com/stretchr/testify/assert "
27+ "github.com/stretchr/testify/require "
2828 "go.mongodb.org/mongo-driver/bson"
2929 "go.mongodb.org/mongo-driver/mongo"
3030 "go.mongodb.org/mongo-driver/mongo/options"
@@ -44,32 +44,32 @@ func TestCollStatsCollectorAccountIndexes(t *testing.T) {
4444
4545 defer func () {
4646 err := database .Drop (ctx )
47- assert .NoError (t , err )
47+ require .NoError (t , err )
4848 }()
4949
5050 collName := "test_collection_account"
5151 coll := database .Collection (collName )
5252
5353 // Insert some data
5454 _ , err := coll .InsertOne (ctx , bson.M {"account_id" : 1 , "count" : 10 })
55- assert .NoError (t , err )
55+ require .NoError (t , err )
5656 _ , err = coll .InsertOne (ctx , bson.M {"account_id" : 2 , "count" : 20 })
57- assert .NoError (t , err )
57+ require .NoError (t , err )
5858
5959 // Create indexes
6060 indexModel := mongo.IndexModel {
6161 Keys : bson.D {{Key : "account_id" , Value : 1 }},
6262 Options : options .Index ().SetName ("test_index_account" ),
6363 }
6464 _ , err = coll .Indexes ().CreateOne (ctx , indexModel )
65- assert .NoError (t , err )
65+ require .NoError (t , err )
6666
6767 indexModel = mongo.IndexModel {
6868 Keys : bson.D {{Key : "count" , Value : 1 }},
6969 Options : options .Index ().SetName ("test_index_count" ),
7070 }
7171 _ , err = coll .Indexes ().CreateOne (ctx , indexModel )
72- assert .NoError (t , err )
72+ require .NoError (t , err )
7373
7474 ti := labelsGetterMock {}
7575
@@ -90,7 +90,7 @@ func TestCollStatsCollectorAccountIndexes(t *testing.T) {
9090 "mongodb_collstats_storageStats_indexSizes" ,
9191 }
9292 err = testutil .CollectAndCompare (c , expected , filter ... )
93- assert .NoError (t , err )
93+ require .NoError (t , err )
9494}
9595
9696func TestCollStatsCollector (t * testing.T ) {
@@ -104,13 +104,13 @@ func TestCollStatsCollector(t *testing.T) {
104104
105105 defer func () {
106106 err := database .Drop (ctx )
107- assert .NoError (t , err )
107+ require .NoError (t , err )
108108 }()
109109
110110 for i := 0 ; i < 3 ; i ++ {
111111 coll := fmt .Sprintf ("testcol_%02d" , i )
112112 _ , err := database .Collection (coll ).InsertOne (ctx , bson.M {"f1" : 1 , "f2" : "2" })
113- assert .NoError (t , err )
113+ require .NoError (t , err )
114114 }
115115
116116 ti := labelsGetterMock {}
@@ -154,5 +154,5 @@ mongodb_collstats_storageStats_capped{collection="testcol_02",database="testdb"}
154154 "mongodb_collstats_latencyStats_transactions_ops" ,
155155 }
156156 err := testutil .CollectAndCompare (c , expected , filter ... )
157- assert .NoError (t , err )
157+ require .NoError (t , err )
158158}
0 commit comments