Skip to content

Commit 7bc9601

Browse files
authored
Merge pull request #120 from FieldDB/fix_replication
Replication to 1.6 couchdb 3.1.2 is working
2 parents 58c7a2f + 2c7615f commit 7bc9601

File tree

6 files changed

+69
-16
lines changed

6 files changed

+69
-16
lines changed

.github/workflows/node.js.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
branches: [ main ]
1111

1212
jobs:
13-
build:
13+
ci:
1414

1515
runs-on: ubuntu-latest
1616

@@ -35,6 +35,26 @@ jobs:
3535
with:
3636
github-token: ${{ secrets.GITHUB_TOKEN }}
3737

38-
- run: DEBUG='none' npm run docker:test
38+
- name: Create local config for tests
39+
run: |
40+
echo 'module.exports = { usersDbConnection: { url: "http://localhost:5984" }};' > config/local.js
3941
env:
4042
SOURCE_URL: ${{ secrets.SOURCE_URL }}
43+
44+
- name: Start docker compose services
45+
run: docker compose up -d
46+
47+
- name: Show docker compose logs
48+
run: docker compose logs --no-color --timestamps || true
49+
50+
- name: Run setup
51+
run: npm run setup
52+
env:
53+
SOURCE_URL: ${{ secrets.SOURCE_URL }}
54+
DEBUG: 'none'
55+
56+
- name: Run tests
57+
run: npm run test:deprecated
58+
env:
59+
SOURCE_URL: ${{ secrets.SOURCE_URL }}
60+
DEBUG: 'none'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ $ npm run docker:test
6161

6262
Turn off the docker container
6363
```bash
64-
$ docker-compose stop
65-
$ docker-compose rm -f
64+
$ docker compose stop
65+
$ docker compose rm -f
6666
```
6767

6868
Exec into the docker container

docker-compose.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
############## Commands ##########################
2-
### docker-compose up -d
3-
### docker-compose logs -f
2+
### docker compose up -d
3+
### docker compose logs -f
44
### docker container list
55

66
############## Docs ##############################
77
# https://hub.docker.com/_/couchdb
88

9-
version: "3.7"
109
services:
1110
couchdb:
1211
build:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
},
7474
"scripts": {
7575
"docker:build": "docker build -t fielddb-auth .",
76-
"docker:test": "echo 'module.exports = { usersDbConnection: { url: \"http://localhost:5984\" } };' > config/local.js && docker compose up -d && docker compose logs && npm run setup && npm run test:deprecated",
76+
"docker:test": "echo 'module.exports = { usersDbConnection: { url: \"http://localhost:5984\" } };' > config/local.js && docker compose up -d && sleep 3 && docker compose logs && npm run setup && npm run test:deprecated",
7777
"docker:test:no-cache": "echo 'module.exports = { usersDbConnection: { url: \"http://localhost:5984\" } };' > config/local.js && docker compose build --no-cache && docker compose up -d && docker compose logs && npm run setup && npm run test:deprecated",
7878
"coverage": "NODE_ENV=test BUNYAN_LOG_LEVEL=FATAL NODE_TLS_REJECT_UNAUTHORIZED=0 nyc npm test",
7979
"coveralls": "cat ./coverage/lcov.info | coveralls",

test/integration/install.js

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe('install', () => {
160160
});
161161

162162
describe('new_testing_corpus', () => {
163-
it.only('should replicate new_testing_corpus', () => {
163+
it('should replicate new_testing_corpus', () => {
164164
const dbnameToReplicate = 'new_testing_corpus';
165165

166166
return supertest(destination)
@@ -192,11 +192,45 @@ describe('install', () => {
192192
})
193193
.then((res) => {
194194
debug('res.body new_testing_corpus design doc for data', res.body);
195-
// FIXME: this design doc throws an error in CouchDB 3.x
196-
// expect(res.body).to.deep.equal({
197-
// rows: [],
198-
// }, JSON.stringify(res.body));
199-
expect(res.body.reason).to.equal('missing', JSON.stringify(res.body));
195+
expect(res.body).to.deep.equal({
196+
rows: [],
197+
}, JSON.stringify(res.body));
198+
});
199+
});
200+
201+
it('should replicate the prototype couchapp', () => {
202+
const dbnameToReplicate = 'prototype';
203+
204+
return supertest(destination)
205+
.post('/_replicate')
206+
.set('cookie', adminSessionCookie)
207+
.set('Accept', 'application/json')
208+
.send({
209+
source: `${source}/${dbnameToReplicate}`,
210+
target: {
211+
url: `${destination}/${dbnameToReplicate}`,
212+
},
213+
create_target: true,
214+
})
215+
.then((res) => {
216+
debug('res.body prototype', res.body);
217+
expect(res.body.ok).to.equal(true);
218+
219+
return supertest(destination)
220+
.get('/_all_dbs')
221+
.set('Accept', 'application/json');
222+
})
223+
.then((res) => {
224+
debug('res.body prototype after', res.body);
225+
expect(res.body).includes(dbnameToReplicate);
226+
227+
return supertest(destination)
228+
.get(`/${dbnameToReplicate}/_design/prototype`)
229+
.set('Accept', 'application/json');
230+
})
231+
.then((res) => {
232+
debug('res.body prototype couchapp', res.body);
233+
expect(res.body.couchapp.name).to.equal(' Prototype (has the most features of the apps)', JSON.stringify(res.body));
200234
});
201235
});
202236
});

test/routes/deprecated-spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('/ deprecated', () => {
3333
* - remove body because the body contains date created timestamps
3434
* - update username to equal the recorded username
3535
*/
36-
it.only('should register a new user', () => {
36+
it('should register a new user', () => {
3737
debug('username', testUsername);
3838
return supertest(authWebService)
3939
.post('/register')
@@ -257,7 +257,7 @@ describe('/ deprecated', () => {
257257

258258
describe('/login', () => {
259259
before(function () {
260-
this.timeout(40000);
260+
this.timeout(140000);
261261

262262
return supertest(authWebService)
263263
.post('/register')

0 commit comments

Comments
 (0)