title: Mocking official MongoDb driver
body: <p>I need to define these interfaces to mock official mongo driver</p>
  
  <pre><code>type MgCollection interface {   
      FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
      // Other methods
  }
  
  type MgDatabase interface {
      Collection(name string, opts ...*options.CollectionOptions) MgCollection
      // Other methods
  }
  </code></pre>
  
  <p>In mongo driver package there are two structs <strong>mongo.Collection</strong> and <strong>mongo.Database</strong> with these methods</p>
  
  <pre><code>func (coll *Collection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *SingleResult {
      // Method code
  }
  
  func (db *Database) Collection(name string, opts ...*options.CollectionOptions) *Collection {
      // Method code
  }
  </code></pre>
  
  <p>The struct <strong>*mongo.Collection</strong> implement <strong>MgCollection</strong> correctly, so this code compiles without error</p>
  
  <pre><code>var col mgdriver.MgCollection
  col = &amp;mongo.Collection{}
  col.FindOne(ctx, nil, nil)
  </code></pre>
  
  <p>But The struct <strong>*mongo.Database</strong> not implement <strong>MgDatabase</strong>, so I when I write something like this:</p>
  
  <pre><code>var db mgdriver.MgDatabase
  db = &amp;mongo.Database{}
  db.Collection("Test", nil)
  </code></pre>
  
  <p>Compiler show this error: </p>
  
  <blockquote>
    <p>cannot use &amp;mongo.Database literal (type *mongo.Database) as type
    mgdriver.MgDatabase in assignment:    *mongo.Database does not implement
    mgdriver.MgDatabase (wrong type for Collection method)        have
    Collection(string, ...*options.CollectionOptions) *mongo.Collection
          want Collection(string, ...*options.CollectionOptions)
    mgdriver.MgCollection</p>
  </blockquote>
  
  <p>Both <strong>mongo.Collection</strong> and <strong>mongo.Database</strong> are in the official package and I cannot change any code in that package. so how can I change my interfaces to mock official mongo driver correctly?</p>