diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3610011a4..e9efd778a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,35 +6,44 @@ variables: COUCHDB_USER: admin COUCHDB_PASSWORD: abc123 -.test: &go_test_template +test: + parallel: + matrix: + - COUCHVER: ["2.2.0", "2.3.1", "3.0.1", "3.1.2", "3.2.3", "3.3.3"] + GOVER: ["1.17", "1.18", "1.19", "1.20", "1.21", "1.22"] stage: test + image: golang:$GOVER services: - - name: couchdb:2.2.0 - alias: couch22 - - name: apache/couchdb:2.3.1 - alias: couch23 - - name: couchdb:3.0.1 - alias: couch30 - - name: couchdb:3.1.2 - alias: couch31 - - name: couchdb:3.2.3 - alias: couch32 - - name: couchdb:3.3.3 - alias: couch33 - variables: - KIVIK_TEST_DSN_COUCH22: http://admin:abc123@couch22:5984/ - KIVIK_TEST_DSN_COUCH23: http://admin:abc123@couch23:5984/ - KIVIK_TEST_DSN_COUCH30: http://admin:abc123@couch30:5984/ - KIVIK_TEST_DSN_COUCH31: http://admin:abc123@couch31:5984/ - KIVIK_TEST_DSN_COUCH32: http://admin:abc123@couch32:5984/ - KIVIK_TEST_DSN_COUCH33: http://admin:abc123@couch33:5984/ + - name: couchdb:$COUCHVER + alias: couch$COUCHVER before_script: - - ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH22} - - ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH23} - - ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH30} - - ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH31} - - ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH32} - - ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH33} + - | + case $COUCHVER in + "2.2.0") + export KIVIK_TEST_DSN_COUCH22=http://$COUCHDB_USER:$COUCHDB_PASSWORD@couch2.2.0:5984/ + ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH22} + ;; + "2.3.1") + export KIVIK_TEST_DSN_COUCH23=http://$COUCHDB_USER:$COUCHDB_PASSWORD@couch2.3.1:5984/ + ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH23} + ;; + "3.0.1") + export KIVIK_TEST_DSN_COUCH30=http://$COUCHDB_USER:$COUCHDB_PASSWORD@couch3.0.1:5984/ + ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH30} + ;; + "3.1.2") + export KIVIK_TEST_DSN_COUCH31=http://$COUCHDB_USER:$COUCHDB_PASSWORD@couch3.1.2:5984/ + ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH31} + ;; + "3.2.3") + export KIVIK_TEST_DSN_COUCH32=http://$COUCHDB_USER:$COUCHDB_PASSWORD@couch3.2.3:5984/ + ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH32} + ;; + "3.3.3") + export KIVIK_TEST_DSN_COUCH33=http://$COUCHDB_USER:$COUCHDB_PASSWORD@couch3.3.3:5984/ + ./script/complete_couch2.sh ${KIVIK_TEST_DSN_COUCH33} + ;; + esac script: - go mod download - go test -race -shuffle=on ./... @@ -59,32 +68,7 @@ coverage: - go mod download - ./script/coverage.sh -go-1.17: - <<: *go_test_template - image: golang:1.17 - -go-1.18: - <<: *go_test_template - image: golang:1.18 - -go-1.19: - <<: *go_test_template - image: golang:1.19 - -go-1.20: - <<: *go_test_template - image: golang:1.20 - -go-1.21: - <<: *go_test_template - image: golang:1.21 - -go-1.22: - <<: *go_test_template - image: golang:1.22 - .gopherjs_test: &gopherjs_test_template - <<: *go_test_template image: golang:1.18 services: - name: couchdb:3.3.3 diff --git a/couchdb/mock_test.go b/couchdb/mock_test.go index ba3384345..d5d686adb 100644 --- a/couchdb/mock_test.go +++ b/couchdb/mock_test.go @@ -134,7 +134,7 @@ func realDB(t *testing.T) *db { func realDBConnect(t *testing.T) (*db, error) { driver := &couch{} - c, err := driver.NewClient(kt.DSN(t), OptionNoRequestCompression()) + c, err := driver.NewClient(kt.DSN3(t), OptionNoRequestCompression()) if err != nil { return nil, err } diff --git a/kiviktest/kt/connect.go b/kiviktest/kt/connect.go index 6c6681754..fd46634e6 100644 --- a/kiviktest/kt/connect.go +++ b/kiviktest/kt/connect.go @@ -20,14 +20,13 @@ import ( kivik "github.com/go-kivik/kivik/v4" ) -// DSN returns a testing DSN from the environment. -func DSN(t *testing.T) string { +// DSN3 returns a testing DSN from the environment for CouchDB 3.x. +func DSN3(t *testing.T) string { for _, env := range []string{ - "KIVIK_TEST_DSN", "KIVIK_TEST_DSN_COUCH33", - "KIVIK_TEST_DSN_COUCH32", "KIVIK_TEST_DSN_COUCH31", - "KIVIK_TEST_DSN_COUCH30", "KIVIK_TEST_DSN_COUCH23", - "KIVIK_TEST_DSN_COUCH22", + "KIVIK_TEST_DSN_COUCH32", + "KIVIK_TEST_DSN_COUCH31", + "KIVIK_TEST_DSN_COUCH30", } { dsn := os.Getenv(env) if dsn != "" { @@ -40,7 +39,7 @@ func DSN(t *testing.T) string { // NoAuthDSN returns a testing DSN with credentials stripped. func NoAuthDSN(t *testing.T) string { - dsn := DSN(t) + dsn := DSN3(t) parsed, err := url.Parse(dsn) if err != nil { t.Fatalf("invalid DSN: %s", err) @@ -59,7 +58,7 @@ func connect(dsn string, t *testing.T) *kivik.Client { // GetClient returns a connection to a CouchDB client, for testing. func GetClient(t *testing.T) *kivik.Client { - return connect(DSN(t), t) + return connect(DSN3(t), t) } // GetNoAuthClient returns an unauthenticated connection to a CouchDB client, for testing. diff --git a/replicate_live_test.go b/replicate_live_test.go index 40631920d..0f8a05f3d 100644 --- a/replicate_live_test.go +++ b/replicate_live_test.go @@ -44,7 +44,7 @@ func TestReplicate_live(t *testing.T) { //nolint:gocyclo // allowed for subtests } tests := testy.NewTable() tests.Add("couch to couch", func(t *testing.T) interface{} { - dsn := kt.DSN(t) + dsn := kt.DSN3(t) client, err := kivik.New("couch", dsn) if err != nil { t.Fatal(err) @@ -87,7 +87,7 @@ func TestReplicate_live(t *testing.T) { //nolint:gocyclo // allowed for subtests if err != nil { t.Fatal(err) } - dsn := kt.DSN(t) + dsn := kt.DSN3(t) client, err := kivik.New("couch", dsn) if err != nil { t.Fatal(err) @@ -119,7 +119,7 @@ func TestReplicate_live(t *testing.T) { //nolint:gocyclo // allowed for subtests if err != nil { t.Fatal(err) } - dsn := kt.DSN(t) + dsn := kt.DSN3(t) client, err := kivik.New("couch", dsn) if err != nil { t.Fatal(err) @@ -151,7 +151,7 @@ func TestReplicate_live(t *testing.T) { //nolint:gocyclo // allowed for subtests } }) tests.Add("couch to couch with sec", func(t *testing.T) interface{} { - dsn := kt.DSN(t) + dsn := kt.DSN3(t) client, err := kivik.New("couch", dsn) if err != nil { t.Fatal(err) @@ -203,7 +203,7 @@ func TestReplicate_live(t *testing.T) { //nolint:gocyclo // allowed for subtests if err != nil { t.Fatal(err) } - dsn := kt.DSN(t) + dsn := kt.DSN3(t) client, err := kivik.New("couch", dsn) if err != nil { t.Fatal(err) @@ -236,7 +236,7 @@ func TestReplicate_live(t *testing.T) { //nolint:gocyclo // allowed for subtests if err != nil { t.Fatal(err) } - dsn := kt.DSN(t) + dsn := kt.DSN3(t) client, err := kivik.New("couch", dsn) if err != nil { t.Fatal(err) @@ -276,7 +276,7 @@ func TestReplicate_live(t *testing.T) { //nolint:gocyclo // allowed for subtests t.Fatal(err) } - dsn := kt.DSN(t) + dsn := kt.DSN3(t) client, err := kivik.New("couch", dsn) if err != nil { t.Fatal(err) @@ -323,7 +323,7 @@ func TestReplicate_live(t *testing.T) { //nolint:gocyclo // allowed for subtests if err != nil { t.Fatal(err) } - dsn := kt.DSN(t) + dsn := kt.DSN3(t) client, err := kivik.New("couch", dsn) if err != nil { t.Fatal(err)