github.com/go-kivik/kivik/v4@v4.3.2/mockdb/util.go (about) 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 ( 16 "fmt" 17 "time" 18 19 kivik "github.com/go-kivik/kivik/v4" 20 ) 21 22 func optionsString(opt kivik.Option) string { 23 if opt == nil { 24 return "\n\t- has any options" 25 } 26 return fmt.Sprintf("\n\t- has options: %s", opt) 27 } 28 29 func errorString(err error) string { 30 if err == nil { 31 return "" 32 } 33 return fmt.Sprintf("\n\t- should return error: %s", err) 34 } 35 36 func delayString(delay time.Duration) string { 37 if delay == 0 { 38 return "" 39 } 40 return fmt.Sprintf("\n\t- should delay for: %s", delay) 41 } 42 43 func fieldString(field, value string) string { 44 if value == "" { 45 return "\n\t- has any " + field 46 } 47 return "\n\t- has " + field + ": " + value 48 }