Documentation ¶
Index ¶
- type Collection
- func (c *Collection) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*Cursor, error)
- func (c *Collection) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
- func (c *Collection) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (c *Collection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
- func (c *Collection) Distinct(ctx context.Context, fieldName string, filter interface{}, ...) ([]interface{}, error)
- func (c *Collection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*Cursor, error)
- func (c *Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *SingleResult
- func (c *Collection) InsertMany(ctx context.Context, documents []interface{}, ...) (*mongo.InsertManyResult, error)
- func (c *Collection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
- func (c *Collection) UpdateMany(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- func (c *Collection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, ...) (*mongo.UpdateResult, error)
- type Cursor
- type SingleResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Collection ¶ added in v0.2.2
type Collection struct { mongo.Collection // contains filtered or unexported fields }
Collection In order to mock mongo operations, mongo collection is embedded into Collection.
func NewCollection ¶ added in v0.2.2
func NewCollection(cl *mongo.Collection) *Collection
NewCollection creates and returns an instance of Collection that contains actual pointer to mongo's collection. This is done in order to mock mongo CRUD operations, so that:
- In keploy.MODE_RECORD mode, stores the encoded output(generated by mocked methods of mongo.Collection) into keploy's Context Deps array.
- In keploy.MODE_TEST mode, decodes its stored encoded output which are present in the keploy's Context Deps array without calling mocked methods of mongo.Collection.
- In "off" mode, returns the output generated after calling mocked method of mongo.Collection.
cl parameter is pointer to mongo's collection instance created by (*mongo.Database).Collection method. It should not be nil, else warning will logged and nil is returned.
Returns pointer to integrations.Collection which contains mongo.Collection. Nil is returned when mongo.Collection is nil.
func (*Collection) Aggregate ¶ added in v0.3.0
func (c *Collection) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*Cursor, error)
Aggregate method mocks Collection.Aggregate of mongo inorder to call it only in keploy.MODE_RECORD or "off" mode.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Collection.Aggregate for more info about Aggregate.
func (*Collection) CountDocuments ¶ added in v0.3.0
func (c *Collection) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
CountDocuments method mocks Collection.CountDocuments of mongo inorder to call it only in keploy.MODE_RECORD or "off" mode.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Collection.CountDocuments for more info about CountDocuments.
func (*Collection) DeleteMany ¶ added in v0.2.2
func (c *Collection) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteMany method mocks Collection.DeleteMany of mongo inorder to call it only in keploy.MODE_RECORD or "off" mode.
See https://pkg.go.dev/go.mongodb.org/mongo-driver@v1.8.0/mongo#Collection.DeleteMany for information about Collection.DeleteMany.
func (*Collection) DeleteOne ¶ added in v0.2.2
func (c *Collection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
DeleteOne method mocks Collection.DeleteOne of mongo.
See https://pkg.go.dev/go.mongodb.org/mongo-driver@v1.8.0/mongo#Collection.DeleteOne for information about Collection.DeleteOne.
func (*Collection) Distinct ¶ added in v0.3.0
func (c *Collection) Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
Distinct method mocks Collection.Distinct of mongo inorder to call it only in keploy.MODE_RECORD or "off" mode.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Collection.Distinct for more info about Distinct.
func (*Collection) Find ¶ added in v0.2.2
func (c *Collection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*Cursor, error)
Find creates and returns the instance of pointer to keploy Cursor struct which have overridden methods of mongo.Cursor. Actual Collection.Find is called only in keploy.MODE_RECORD or "off" mode.
For information about Collection.Find, See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Collection.Find.
func (*Collection) FindOne ¶ added in v0.2.2
func (c *Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *SingleResult
FindOne method creates and returns pointer of SingleResult which containes mongo.SingleResult in order to mock its method. It mocks Collection.FindOne method explained above in integrations.NewCollections.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Collection.FindOne for information about Collection.FindOne.
func (*Collection) InsertMany ¶ added in v0.2.2
func (c *Collection) InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
InsertMany method mocks Collection.InsertMany of mongo.
For information about Collection.InsertMany, visit https://pkg.go.dev/go.mongodb.org/mongo-driver@v1.8.0/mongo#Collection.InsertMany.
func (*Collection) InsertOne ¶ added in v0.2.2
func (c *Collection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
InsertOne method mocks Collection.InsertOne of mongo.Collection. Actual method isn't called in test mode only as stated in integrations.NewCollection.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Collection.InsertOne for information about Collection.InsertOne.
func (*Collection) UpdateMany ¶ added in v0.2.2
func (c *Collection) UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateMany method mocks Collection.UpdateMany of mongo.
For information about Collection.UpdateMany, go to https://pkg.go.dev/go.mongodb.org/mongo-driver@v1.8.0/mongo#Collection.UpdateMany.
func (*Collection) UpdateOne ¶ added in v0.2.2
func (c *Collection) UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
UpdateOne method mocks Collection.UpdateOne of mongo.
For information about Collection.UpdateOne, refer to https://pkg.go.dev/go.mongodb.org/mongo-driver@v1.8.0/mongo#Collection.UpdateOne.
type Cursor ¶ added in v0.2.2
Cursor contains emedded mongo.Cursor in order to override its methods.
func (*Cursor) All ¶ added in v0.2.2
All mocks mongo's Cursor.All in order to store and replay its output according SDK mode.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Cursor.All for information about Cursor.All.
func (*Cursor) Close ¶ added in v0.2.2
Close mocks mongo's Cursor.Close in order to store and replay its output according SDK mode.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Cursor.Close for information about Cursor.Close.
func (*Cursor) Decode ¶ added in v0.2.2
Decode mocks mongo's Cursor.Decode in order to store and replay its output according SDK mode.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Cursor.Decode for information about Cursor.Decode.
func (*Cursor) Err ¶ added in v0.2.2
Err mocks mongo's Cursor.Err in order to store and replay its output according SDK mode.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Cursor.Err for information about Cursor.Err.
func (*Cursor) Next ¶ added in v0.2.2
Next mocks mongo's Cursor.Next in order to store and replay its output according SDK mode.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#Cursor.Next for information about Cursor.Next.
type SingleResult ¶ added in v0.2.2
type SingleResult struct { mongo.SingleResult // contains filtered or unexported fields }
SingleResult countains instance of mongo.SingleResult to mock its methods so that:
- In keploy.MODE_RECORD mode, stores the encoded output(generated by mocked methods of mongo.SingleResult) into keploy's Context Deps array.
- In keploy.MODE_TEST mode, decodes its stored encoded output which are present in the keploy's Context Deps array without calling mocked methods of mongo.SingleResult.
- In "off" mode, returns the output generated after calling mocked method of mongo.SingleResult.
func (*SingleResult) Decode ¶ added in v0.2.2
func (msr *SingleResult) Decode(v interface{}) error
Decode mocks mongo's SingleResult.Decode which will called in keploy.MODE_RECORD or "off" mode as stated above in SingleResult.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#SingleResult.Decode for more information about SingleResult.Decode.
func (*SingleResult) Err ¶ added in v0.2.2
func (msr *SingleResult) Err() error
Err mocks mongo's SingleResult Err() which will called in keploy.MODE_RECORD or "off" mode as stated above in SingleResult.
See https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo#SingleResult.Err for more information about SingleResult.Err.