...

Source file src/github.com/go-kivik/kivik/v4/mockdb/dbmock.go

Documentation: github.com/go-kivik/kivik/v4/mockdb

     1  // Licensed under the Apache License, Version 2.0 (the "License"); you may not
     2  // use this file except in compliance with the License. You may obtain a copy of
     3  // the License at
     4  //
     5  //  http://www.apache.org/licenses/LICENSE-2.0
     6  //
     7  // Unless required by applicable law or agreed to in writing, software
     8  // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
     9  // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    10  // License for the specific language governing permissions and limitations under
    11  // the License.
    12  
    13  package mockdb
    14  
    15  import "sync"
    16  
    17  // DB serves to create expectations for database actions to mock and test real
    18  // database behavior.
    19  type DB struct {
    20  	name   string
    21  	id     int
    22  	client *Client
    23  	count  int
    24  	mu     sync.RWMutex
    25  }
    26  
    27  func (db *DB) expectations() int {
    28  	return db.count
    29  }
    30  
    31  // ExpectClose queues an expectation for DB.Close() to be called.
    32  func (db *DB) ExpectClose() *ExpectedDBClose {
    33  	e := &ExpectedDBClose{
    34  		commonExpectation: commonExpectation{db: db},
    35  	}
    36  	db.count++
    37  	db.client.expected = append(db.client.expected, e)
    38  	return e
    39  }
    40  

View as plain text