Skip to content

Commit

Permalink
Merge pull request #214 from flimzy/couch21
Browse files Browse the repository at this point in the history
Add support for CouchDB 2.1.x
  • Loading branch information
flimzy authored Oct 24, 2017
2 parents bdc1a6f + ded26bd commit 26f2d6e
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ env:
global:
- KIVIK_TEST_DSN_COUCH16="http://admin:abc123@localhost:6000/"
- KIVIK_TEST_DSN_COUCH20="http://admin:abc123@localhost:6001/"
- KIVIK_TEST_DSN_COUCH21="http://admin:abc123@localhost:6002/"
- HOMEBREW_NO_AUTO_UPDATE=1
matrix:
- MODE=standard
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ me know by submitting a bug report via GitHub.

- **Go** Kivik 1.x aims for full compatibility with all stable releases of Go from 1.7.
- **CouchDB** The Kivik 1.x CouchDB driver aims for compatibility with all stable releases of
CouchDB from 1.6.1.
CouchDB from 1.6.1. CouchDB 2.1.x support is not yet complete. Follow [#174](https://github.com/flimzy/kivik/issues/174) for details.
- **GopherJS** GopherJS always requires the latest stable version of Go, so building Kivik with
GopherJS has this same requirement.
- **PouchDB** The Kivik 1.x PouchDB driver aims for compatibility with all stable releases of
Expand Down
1 change: 1 addition & 0 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const (
StatusRequestTimeout = 408
StatusConflict = 409
StatusPreconditionFailed = 412
StatusStatusRequestEntityTooLarge = 413
StatusBadContentType = 415
StatusRequestedRangeNotSatisfiable = 416
StatusExpectationFailed = 417
Expand Down
2 changes: 0 additions & 2 deletions doc/COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
| HTTP Basic Auth | ✅ | ✅ | ✅ | ✅<sup>[1](#pouchDbAuth)</sup> | ⁿ/ₐ | ⁿ/ₐ<sup>[2](#fsAuth)</sup>
| Cookie Auth | ✅ | ✅ | ✅<sup>[3](#couchGopherJSAuth)</sup> | | ⁿ/ₐ | ⁿ/ₐ<sup>[2](#fsAuth)</sup>
| Proxy Auth | | | | | ⁿ/ₐ | ⁿ/ₐ<sup>[2](#fsAuth)</sup>
| OAuth 1.0 | | | | | ⁿ/ₐ | ⁿ/ₐ<sup>[2](#fsAuth)</sup>
| OAuth 2.0 | | | ⁿ/ₐ | ⁿ/ₐ | ⁿ/ₐ | ⁿ/ₐ

### Notes

Expand Down
2 changes: 1 addition & 1 deletion driver/couchdb/chttp/chttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

func dsn(t *testing.T) string {
for _, env := range []string{"KIVIK_TEST_DSN_COUCH16", "KIVIK_TEST_DSN_COUCH20", "KIVIK_TEST_DSN_CLOUDANT"} {
for _, env := range []string{"KIVIK_TEST_DSN_COUCH21", "KIVIK_TEST_DSN_COUCH20", "KIVIK_TEST_DSN_COUCH16", "KIVIK_TEST_DSN_CLOUDANT"} {
dsn := os.Getenv(env)
if dsn != "" {
return dsn
Expand Down
3 changes: 3 additions & 0 deletions driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ type Version struct {
Version string
// Vendor is the vendor string reported by the server or backend.
Vendor string
// Features is a list of enabled, optional features. This was added in
// CouchDB 2.1.0, and can be expected to be empty for older versions.
Features []string
// RawResponse is the raw response body as returned by the server.
RawResponse json.RawMessage
}
Expand Down
2 changes: 1 addition & 1 deletion proxy/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestNew(t *testing.T) {
}

func serverDSN(t *testing.T) string {
for _, env := range []string{"KIVIK_TEST_DSN_COUCH16", "KIVIK_TEST_DSN_COUCH20"} {
for _, env := range []string{"KIVIK_TEST_DSN_COUCH21", "KIVIK_TEST_DSN_COUCH20", "KIVIK_TEST_DSN_COUCH16"} {
if dsn := os.Getenv(env); dsn != "" {
parsed, err := url.Parse(dsn)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions test/couchdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ func TestCloudant(t *testing.T) {
func TestCouch20(t *testing.T) {
kiviktest.DoTest(kiviktest.SuiteCouch20, "KIVIK_TEST_DSN_COUCH20", t)
}

func TestCouch21(t *testing.T) {
kiviktest.DoTest(kiviktest.SuiteCouch21, "KIVIK_TEST_DSN_COUCH21", t)
}
17 changes: 16 additions & 1 deletion travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,24 @@ function setup_couch20 {
curl --silent --fail -o /dev/null -X PUT http://admin:abc123@localhost:6001/_global_changes
}

function setup_couch21 {
if [ "$TRAVIS_OS_NAME" == "osx" ]; then
return
fi
docker pull apache/couchdb:2.1.0
docker run -d -p 6002:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=abc123 --name couchdb21 apache/couchdb:2.1.0
wait_for_server http://localhost:6002/
curl --silent --fail -o /dev/null -X PUT http://admin:abc123@localhost:6002/_users
curl --silent --fail -o /dev/null -X PUT http://admin:abc123@localhost:6002/_replicator
curl --silent --fail -o /dev/null -X PUT http://admin:abc123@localhost:6002/_global_changes
curl --silent --fail -o /dev/null -X PUT http://admin:abc123@localhost:6002/_node/nonode@nohost/_config/replicator/update_docs -H 'Content-Type: application/json' -d '"true"' # FIXME: https://github.com/flimzy/kivik/issues/215
}

case "$1" in
"standard")
setup_couch16
setup_couch20
setup_couch21
generate
;;
"gopherjs")
Expand Down Expand Up @@ -80,7 +94,7 @@ case "$1" in
)

go get -u -d -tags=js github.com/gopherjs/jsbuiltin
setup_couch20
setup_couch21
generate
;;
"linter")
Expand All @@ -90,6 +104,7 @@ case "$1" in
"coverage")
setup_couch16
setup_couch20
setup_couch21
generate
;;
esac
5 changes: 4 additions & 1 deletion travis/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ if [ "${TRAVIS_OS_NAME:-}" == "osx" ]; then
# We don't have docker in OSX, so skip these tests
unset KIVIK_TEST_DSN_COUCH16
unset KIVIK_TEST_DSN_COUCH20
unset KIVIK_TEST_DSN_COUCH21
fi

function join_list {
Expand All @@ -18,6 +19,7 @@ case "$1" in
;;
"gopherjs")
unset KIVIK_TEST_DSN_COUCH16
unset KIVIK_TESt_DSN_COUCH20
gopherjs test $(go list ./... | grep -v /vendor/ | grep -Ev 'kivik/(serve|auth|proxy)')
;;
"linter")
Expand Down Expand Up @@ -45,9 +47,10 @@ case "$1" in
--exclude="Errors unhandled\..*\(gas\)" # This is an annoying duplicate of errcheck
;;
"coverage")
# Use only CouchDB 2.0 for the coverage tests, primarily because CouchDB
# Use only CouchDB 2.1 for the coverage tests, primarily because CouchDB
# 1.6 is sporadic with failures, and leads to fluctuating coverage stats.
unset KIVIK_TEST_DSN_COUCH16
unset KIVIK_TEST_DSN_COUCH20
echo "" > coverage.txt

TEST_PKGS=$(find -name "*_test.go" | grep -v /vendor/ | grep -v /pouchdb | xargs dirname | sort -u | sed -e "s#^\.#github.com/flimzy/kivik#" )
Expand Down

0 comments on commit 26f2d6e

Please sign in to comment.