@@ -18,7 +18,8 @@ func Test_Client_CreateDB(t *testing.T) {
1818 ctx := context .Background ()
1919 database := "testDB"
2020
21- mockArango .EXPECT ().CreateDatabase (gomock .Any (), database , nil ).Return (nil )
21+ mockArango .EXPECT ().DatabaseExists (gomock .Any (), gomock .Any ()).Return (false , nil )
22+ mockArango .EXPECT ().CreateDatabase (gomock .Any (), database , nil ).Return (nil , nil )
2223 mockLogger .EXPECT ().Debug (gomock .Any ()).AnyTimes ()
2324 mockMetrics .EXPECT ().RecordHistogram (gomock .Any (), "app_arango_stats" , gomock .Any (),
2425 gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).AnyTimes ()
@@ -33,7 +34,8 @@ func Test_Client_CreateDB_Error(t *testing.T) {
3334 ctx := context .Background ()
3435 database := "errorDB"
3536
36- mockArango .EXPECT ().CreateDatabase (gomock .Any (), database , nil ).Return (errDBNotFound )
37+ mockArango .EXPECT ().DatabaseExists (gomock .Any (), gomock .Any ()).Return (false , errDBNotFound )
38+ mockArango .EXPECT ().CreateDatabase (gomock .Any (), database , nil ).Return (nil , errDBNotFound )
3739 mockLogger .EXPECT ().Debug (gomock .Any ()).AnyTimes ()
3840 mockMetrics .EXPECT ().RecordHistogram (gomock .Any (), "app_arango_stats" , gomock .Any (),
3941 gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).AnyTimes ()
@@ -44,11 +46,12 @@ func Test_Client_CreateDB_Error(t *testing.T) {
4446}
4547
4648func Test_Client_CreateDB_AlreadyExists (t * testing.T ) {
47- client , _ , _ , mockLogger , mockMetrics := setupDB (t )
49+ client , mockArango , _ , mockLogger , mockMetrics := setupDB (t )
4850
4951 ctx := context .Background ()
5052 database := "dbExists"
5153
54+ mockArango .EXPECT ().DatabaseExists (gomock .Any (), gomock .Any ()).Return (true , nil )
5255 mockLogger .EXPECT ().Debugf ("database %s already exists" , database )
5356 mockLogger .EXPECT ().Debug (gomock .Any ()).AnyTimes ()
5457 mockMetrics .EXPECT ().RecordHistogram (gomock .Any (), "app_arango_stats" , gomock .Any (),
@@ -63,11 +66,12 @@ func Test_Client_DropDB(t *testing.T) {
6366
6467 ctx := context .Background ()
6568 database := "testDB"
66- mockDB := NewMockDatabase (gomock .NewController (t ))
69+ ctrl := gomock .NewController (t )
70+ mockDB := NewMockDatabase (ctrl )
6771
6872 // Mock the database method to return a mock database instance
6973 mockArango .EXPECT ().GetDatabase (gomock .Any (), database , & arangodb.GetDatabaseOptions {}).
70- Return (mockDB , nil ).Times (1 )
74+ Return (arangodb . Database ( mockDB ) , nil ).Times (1 )
7175 mockDB .EXPECT ().Remove (gomock .Any ()).Return (nil ).Times (1 )
7276 mockLogger .EXPECT ().Debug (gomock .Any ()).AnyTimes ()
7377 mockMetrics .EXPECT ().RecordHistogram (gomock .Any (), "app_arango_stats" , gomock .Any (),
@@ -114,10 +118,10 @@ func Test_Client_CreateCollection(t *testing.T) {
114118 client , mockArango , _ , mockLogger , mockMetrics := setupDB (t )
115119 mockDB := NewMockDatabase (gomock .NewController (t ))
116120
117- mockArango .EXPECT ().GetDatabase (gomock .Any (), "testDB" , & arangodb. GetDatabaseOptions {} ).
121+ mockArango .EXPECT ().GetDatabase (gomock .Any (), "testDB" , nil ).
118122 Return (mockDB , nil )
119123 mockDB .EXPECT ().CollectionExists (gomock .Any (), "testCollection" ).Return (false , nil )
120- mockDB .EXPECT ().CreateCollection (gomock .Any (), "testCollection" , gomock .Any ()).Return (nil , nil )
124+ mockDB .EXPECT ().CreateCollectionV2 (gomock .Any (), "testCollection" , gomock .Any ()).Return (nil , nil )
121125 mockLogger .EXPECT ().Debug (gomock .Any ()).AnyTimes ()
122126 mockMetrics .EXPECT ().RecordHistogram (gomock .Any (), "app_arango_stats" , gomock .Any (),
123127 gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).AnyTimes ()
@@ -130,10 +134,10 @@ func Test_Client_CreateCollection_Error(t *testing.T) {
130134 client , mockArango , _ , mockLogger , mockMetrics := setupDB (t )
131135 mockDB := NewMockDatabase (gomock .NewController (t ))
132136
133- mockArango .EXPECT ().GetDatabase (gomock .Any (), "testDB" , & arangodb. GetDatabaseOptions {} ).
137+ mockArango .EXPECT ().GetDatabase (gomock .Any (), "testDB" , nil ).
134138 Return (mockDB , nil )
135139 mockDB .EXPECT ().CollectionExists (gomock .Any (), "testCollection" ).Return (false , nil )
136- mockDB .EXPECT ().CreateCollection (gomock .Any (), "testCollection" , gomock .Any ()).Return (nil , errCollectionNotFound )
140+ mockDB .EXPECT ().CreateCollectionV2 (gomock .Any (), "testCollection" , gomock .Any ()).Return (nil , errCollectionNotFound )
137141 mockLogger .EXPECT ().Debug (gomock .Any ()).AnyTimes ()
138142 mockMetrics .EXPECT ().RecordHistogram (gomock .Any (), "app_arango_stats" , gomock .Any (),
139143 gomock .Any (), gomock .Any (), gomock .Any (), gomock .Any ()).AnyTimes ()
@@ -147,7 +151,7 @@ func Test_Client_CreateCollection_AlreadyExists(t *testing.T) {
147151 client , mockArango , _ , mockLogger , mockMetrics := setupDB (t )
148152 mockDB := NewMockDatabase (gomock .NewController (t ))
149153
150- mockArango .EXPECT ().GetDatabase (gomock .Any (), "dbExists" , & arangodb. GetDatabaseOptions {} ).
154+ mockArango .EXPECT ().GetDatabase (gomock .Any (), "dbExists" , nil ).
151155 Return (mockDB , nil )
152156 mockDB .EXPECT ().CollectionExists (gomock .Any (), "testCollection" ).Return (true , nil )
153157 mockLogger .EXPECT ().Debug (gomock .Any ()).AnyTimes ()
@@ -162,12 +166,14 @@ func Test_Client_CreateCollection_AlreadyExists(t *testing.T) {
162166
163167func Test_Client_DropCollection (t * testing.T ) {
164168 client , mockArango , _ , mockLogger , mockMetrics := setupDB (t )
165- mockDB := NewMockDatabase (gomock .NewController (t ))
166- mockCollection := NewMockCollection (gomock .NewController (t ))
169+ ctrl := gomock .NewController (t )
170+ mockDB := NewMockDatabase (ctrl )
171+ mockCollection := NewMockCollection (ctrl )
167172
168- mockArango .EXPECT ().GetDatabase (gomock .Any (), "testDB" , & arangodb. GetDatabaseOptions {} ).
173+ mockArango .EXPECT ().GetDatabase (gomock .Any (), "testDB" , nil ).
169174 Return (mockDB , nil )
170- mockDB .EXPECT ().GetCollection (gomock .Any (), "testCollection" , nil ).Return (mockCollection , nil )
175+ mockDB .EXPECT ().GetCollection (gomock .Any (), "testCollection" , nil ).
176+ Return (mockCollection , nil )
171177 mockCollection .EXPECT ().Remove (gomock .Any ()).Return (nil )
172178 mockLogger .EXPECT ().Debug (gomock .Any ()).AnyTimes ()
173179 mockMetrics .EXPECT ().RecordHistogram (gomock .Any (), "app_arango_stats" ,
@@ -182,7 +188,7 @@ func Test_Client_DropCollection_Error(t *testing.T) {
182188 client , mockArango , _ , mockLogger , mockMetrics := setupDB (t )
183189 mockDB := NewMockDatabase (gomock .NewController (t ))
184190
185- mockArango .EXPECT ().GetDatabase (gomock .Any (), "testDB" , & arangodb. GetDatabaseOptions {} ).
191+ mockArango .EXPECT ().GetDatabase (gomock .Any (), "testDB" , nil ).
186192 Return (mockDB , nil )
187193 mockDB .EXPECT ().GetCollection (gomock .Any (), "testCollection" , nil ).
188194 Return (nil , errCollectionNotFound )
0 commit comments