...
1
2
3
4
5
6
7
8
9
10
11
12
13 package cdb
14
15 import (
16 "net/http"
17 "testing"
18
19 "gitlab.com/flimzy/testy"
20
21 internal "github.com/go-kivik/kivik/v4/int/errors"
22 "github.com/go-kivik/kivik/v4/x/fsdb/filesystem"
23 )
24
25 func TestAttachmentsIterator(t *testing.T) {
26 type tt struct {
27 r *Revision
28 status int
29 err string
30 }
31 tests := testy.NewTable()
32 tests.Add("missing attachment", tt{
33 r: &Revision{
34 options: map[string]interface{}{
35 "attachments": true,
36 },
37 RevMeta: RevMeta{
38 Attachments: map[string]*Attachment{
39 "notfound.txt": {
40 fs: filesystem.Default(),
41 path: "/somewhere/notfound.txt",
42 },
43 },
44 },
45 },
46 status: http.StatusInternalServerError,
47 err: "open /somewhere/notfound.txt: [Nn]o such file or directory",
48 })
49 tests.Run(t, func(t *testing.T, tt tt) {
50 _, err := tt.r.AttachmentsIterator()
51 if d := internal.StatusErrorDiffRE(tt.err, tt.status, err); d != "" {
52 t.Error(d)
53 }
54 })
55 }
56
View as plain text