1package kivik
2
3import (
4	"errors"
5	"io"
6	"io/ioutil"
7	"strings"
8	"testing"
9	"time"
10)
11
12var testOptions = map[string]interface{}{"foo": 123}
13
14func parseTime(t *testing.T, str string) time.Time {
15	ts, err := time.Parse(time.RFC3339, str)
16	if err != nil {
17		t.Fatal(err)
18	}
19	return ts
20}
21
22type errReader string
23
24var _ io.ReadCloser = errReader("")
25
26func (r errReader) Close() error {
27	return nil
28}
29
30func (r errReader) Read(_ []byte) (int, error) {
31	return 0, errors.New(string(r))
32}
33
34func body(s string) io.ReadCloser {
35	return ioutil.NopCloser(strings.NewReader(s))
36}
37
38type mockIterator struct {
39	NextFunc  func(interface{}) error
40	CloseFunc func() error
41}
42
43var _ iterator = &mockIterator{}
44
45func (i *mockIterator) Next(ifce interface{}) error {
46	return i.NextFunc(ifce)
47}
48
49func (i *mockIterator) Close() error {
50	return i.CloseFunc()
51}
52