-
Notifications
You must be signed in to change notification settings - Fork 42
/
test.go
124 lines (101 loc) · 4.87 KB
/
test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
// use this file except in compliance with the License. You may obtain a copy of
// the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations under
// the License.
package test
import (
"context"
"net/http"
"testing"
"github.com/go-kivik/kivik/v4"
"github.com/go-kivik/kivik/v4/kiviktest"
"github.com/go-kivik/kivik/v4/kiviktest/kt"
)
// RegisterMemoryDBSuite registers the MemoryDB integration test suite.
func RegisterMemoryDBSuite() {
kiviktest.RegisterSuite(kiviktest.SuiteKivikMemory, kt.SuiteConfig{
// Unsupported features
"Flush.skip": true,
"AllDBs.expected": []string{"_users"},
"CreateDB/RW/NoAuth.status": http.StatusUnauthorized,
"CreateDB/RW/Admin/Recreate.status": http.StatusPreconditionFailed,
"AllDocs.skip": true, // FIXME: Unimplemented
"DBExists/Admin.databases": []string{"chicken"},
"DBExists/Admin/chicken.exists": false,
"DBExists/RW/group/Admin.exists": true,
"AllDBsStats.expected": []*kivik.DBStats{
{
Name: "_users",
},
},
"DestroyDB/RW/Admin/NonExistantDB.status": http.StatusNotFound,
"Log.status": http.StatusNotImplemented,
"Log/Admin/HTTP.skip": true,
"Version.version": `^0\.0\.1$`,
"Version.vendor": `^Kivik Memory Adaptor$`,
"Version.vendor_version": `^0\.0\.1$`,
// Replications not to be implemented
"GetReplications.skip": true,
"Replicate.skip": true,
"Get/RW/group/Admin/bogus.status": http.StatusNotFound,
"GetRev/RW/group/Admin/bogus.status": http.StatusNotFound,
"Put/RW/Admin/group/LeadingUnderscoreInID.status": http.StatusBadRequest,
"Put/RW/Admin/group/Conflict.status": http.StatusConflict,
"Delete/RW/Admin/group/MissingDoc.status": http.StatusNotFound,
"Delete/RW/Admin/group/InvalidRevFormat.status": http.StatusBadRequest,
"Delete/RW/Admin/group/WrongRev.status": http.StatusConflict,
"Security.databases": []string{"_users", "chicken", "_duck"},
"Security/Admin/chicken.status": http.StatusNotFound,
"Security/Admin/_duck.status": http.StatusNotFound,
"SetSecurity/RW/Admin/NotExists.status": http.StatusNotFound,
"BulkDocs/RW/NoAuth/group/Mix/Conflict.status": http.StatusConflict,
"BulkDocs/RW/Admin/group/Mix/Conflict.status": http.StatusConflict,
"Find.databases": []string{"chicken", "_duck"},
"Find/Admin/chicken.status": http.StatusNotFound,
"Find/Admin/_duck.status": http.StatusNotFound,
"Find/NoAuth/chicken.status": http.StatusNotFound,
"Find/NoAuth/_duck.status": http.StatusUnauthorized,
"Find/RW/group/Admin/Warning.warning": "no matching index found, create an index to optimize query time",
"Find/RW/group/NoAuth/Warning.warning": "no matching index found, create an index to optimize query time",
"Explain.skip": true, // FIXME: Unimplemented
"Stats.skip": true, // FIXME: Unimplemented
"Compact.skip": true, // FIXME: Unimplemented
"DBUpdates.status": http.StatusNotImplemented, // FIXME: Unimplemented
"Changes.skip": true, // FIXME: Unimplemented
"Copy.skip": true, // FIXME: Unimplemented, depends on Get/Put or Copy
"GetAttachment.skip": true, // FIXME: Unimplemented
"GetAttachmentMeta.skip": true, // FIXME: Unimplemented
"PutAttachment.skip": true, // FIXME: Unimplemented
"DeleteAttachment.skip": true, // FIXME: Unimplemented
"Query.skip": true, // FIXME: Unimplemented
"CreateIndex.skip": true, // FIXME: Unimplemented
"GetIndexes.skip": true, // FIXME: Unimplemented
"DeleteIndex.skip": true, // FIXME: Unimplemented
"SetSecurity.skip": true, // FIXME: Unimplemented
"ViewCleanup.skip": true, // FIXME: Unimplemented
})
}
// MemoryTest runs the integration tests for the Memory driver.
func MemoryTest(t *testing.T) {
client, err := kivik.New("memory", "")
if err != nil {
t.Errorf("Failed to connect to memory driver: %s\n", err)
return
}
clients := &kt.Context{
RW: true,
Admin: client,
T: t,
}
if err := client.CreateDB(context.Background(), "_users"); err != nil {
t.Fatal(err)
}
kiviktest.RunTestsInternal(clients, kiviktest.SuiteKivikMemory)
}