-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.go
35 lines (27 loc) · 782 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package mongo
import (
"context"
"github.com/renanferr/planets-api/pkg/storage/mongo"
"go.mongodb.org/mongo-driver/mongo/readpref"
)
type ClientMock struct {
DB mongo.Database
ConnectErr error
DisconectErr error
PingErr error
}
func NewClientMock(db mongo.Database, connectErr error, disconnectErr error, pingErr error) *ClientMock {
return &ClientMock{db, connectErr, disconnectErr, pingErr}
}
func (m *ClientMock) Database(databaseName string) mongo.Database {
return m.DB
}
func (m *ClientMock) Connect(ctx context.Context) error {
return m.ConnectErr
}
func (m *ClientMock) Disconnect(ctx context.Context) error {
return m.DisconectErr
}
func (m *ClientMock) Ping(ctx context.Context, readpref *readpref.ReadPref) error {
return m.PingErr
}