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 mock 14 15 import "github.com/go-kivik/kivik/v4/driver" 16 17 // DBUpdates mocks driver.DBUpdates 18 type DBUpdates struct { 19 // ID identifies a specific DBUpdates instance. 20 ID string 21 NextFunc func(*driver.DBUpdate) error 22 CloseFunc func() error 23 } 24 25 var _ driver.DBUpdates = &DBUpdates{} 26 27 // Next calls u.NextFunc 28 func (u *DBUpdates) Next(dbupdate *driver.DBUpdate) error { 29 return u.NextFunc(dbupdate) 30 } 31 32 // Close calls u.CloseFunc 33 func (u *DBUpdates) Close() error { 34 if u.CloseFunc != nil { 35 return u.CloseFunc() 36 } 37 return nil 38 } 39 40 // LastSeqer mocks driver.DBUpdates and driver.LastSeqer. 41 type LastSeqer struct { 42 *DBUpdates 43 LastSeqFunc func() (string, error) 44 } 45 46 var _ driver.LastSeqer = &LastSeqer{} 47 48 // LastSeq calls l.LastSeqFunc. 49 func (l *LastSeqer) LastSeq() (string, error) { 50 return l.LastSeqFunc() 51 } 52