Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
branches: [ main ]

jobs:
build:
ci:

runs-on: ubuntu-latest

Expand All @@ -35,6 +35,26 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- run: DEBUG='none' npm run docker:test
- name: Create local config for tests
run: |
echo 'module.exports = { usersDbConnection: { url: "http://localhost:5984" }};' > config/local.js
env:
SOURCE_URL: ${{ secrets.SOURCE_URL }}

- name: Start docker compose services
run: docker compose up -d

- name: Show docker compose logs
run: docker compose logs --no-color --timestamps || true

- name: Run setup
run: npm run setup
env:
SOURCE_URL: ${{ secrets.SOURCE_URL }}
DEBUG: 'none'

- name: Run tests
run: npm run test:deprecated
env:
SOURCE_URL: ${{ secrets.SOURCE_URL }}
DEBUG: 'none'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ $ npm run docker:test

Turn off the docker container
```bash
$ docker-compose stop
$ docker-compose rm -f
$ docker compose stop
$ docker compose rm -f
```

Exec into the docker container
Expand Down
5 changes: 2 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
############## Commands ##########################
### docker-compose up -d
### docker-compose logs -f
### docker compose up -d
### docker compose logs -f
### docker container list

############## Docs ##############################
# https://hub.docker.com/_/couchdb

version: "3.7"
services:
couchdb:
build:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
},
"scripts": {
"docker:build": "docker build -t fielddb-auth .",
"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",
"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",
"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",
"coverage": "NODE_ENV=test BUNYAN_LOG_LEVEL=FATAL NODE_TLS_REJECT_UNAUTHORIZED=0 nyc npm test",
"coveralls": "cat ./coverage/lcov.info | coveralls",
Expand Down
46 changes: 40 additions & 6 deletions test/integration/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ describe('install', () => {
});

describe('new_testing_corpus', () => {
it.only('should replicate new_testing_corpus', () => {
it('should replicate new_testing_corpus', () => {
const dbnameToReplicate = 'new_testing_corpus';

return supertest(destination)
Expand Down Expand Up @@ -192,11 +192,45 @@ describe('install', () => {
})
.then((res) => {
debug('res.body new_testing_corpus design doc for data', res.body);
// FIXME: this design doc throws an error in CouchDB 3.x
// expect(res.body).to.deep.equal({
// rows: [],
// }, JSON.stringify(res.body));
expect(res.body.reason).to.equal('missing', JSON.stringify(res.body));
expect(res.body).to.deep.equal({
rows: [],
}, JSON.stringify(res.body));
});
});

it('should replicate the prototype couchapp', () => {
const dbnameToReplicate = 'prototype';

return supertest(destination)
.post('/_replicate')
.set('cookie', adminSessionCookie)
.set('Accept', 'application/json')
.send({
source: `${source}/${dbnameToReplicate}`,
target: {
url: `${destination}/${dbnameToReplicate}`,
},
create_target: true,
})
.then((res) => {
debug('res.body prototype', res.body);
expect(res.body.ok).to.equal(true);

return supertest(destination)
.get('/_all_dbs')
.set('Accept', 'application/json');
})
.then((res) => {
debug('res.body prototype after', res.body);
expect(res.body).includes(dbnameToReplicate);

return supertest(destination)
.get(`/${dbnameToReplicate}/_design/prototype`)
.set('Accept', 'application/json');
})
.then((res) => {
debug('res.body prototype couchapp', res.body);
expect(res.body.couchapp.name).to.equal(' Prototype (has the most features of the apps)', JSON.stringify(res.body));
});
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/routes/deprecated-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('/ deprecated', () => {
* - remove body because the body contains date created timestamps
* - update username to equal the recorded username
*/
it.only('should register a new user', () => {
it('should register a new user', () => {
debug('username', testUsername);
return supertest(authWebService)
.post('/register')
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('/ deprecated', () => {

describe('/login', () => {
before(function () {
this.timeout(40000);
this.timeout(140000);

return supertest(authWebService)
.post('/register')
Expand Down
Loading