test(registry): lib to start and stop an npm-registry-couchapp

This commit is contained in:
Stephan Bönnemann
2015-07-09 02:10:38 +02:00
parent 4093bb2dbe
commit 32c1dcf75b
6 changed files with 65 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
const { exec } = require('child_process')
const { join } = require('path')
const opts = {
cwd: join(__dirname, '../../test/registry')
}
module.exports = {
start: exec.bind(null, './start.sh', opts),
stop: exec.bind(null, './stop.sh', opts),
uri: 'http://localhost:5984/registry/_design/app/_rewrite/'
}
+16
View File
@@ -0,0 +1,16 @@
[couch_httpd_auth]
public_fields = appdotnet, avatar, avatarMedium, avatarLarge, date, email, fields, freenode, fullname, github, homepage, name, roles, twitter, type, _id, _rev
users_db_public = true
[httpd]
bind_address = 0.0.0.0
secure_rewrites = false
[couchdb]
delayed_commits = false
[admins]
admin = -pbkdf2-89582b49cd2e8443e29a841f5a76d367956a8e58,1afa2f1531a17ac97f2ac9e334293753,10
[log]
level = none
+25
View File
@@ -0,0 +1,25 @@
#!/bin/bash
# exit if an error occurs
set -e
cd $(dirname $0)
# start couchdb as a background process, reset config, load local config
couchdb -b -a local.ini
COUCH=http://admin:password@127.0.0.1:5984
# create "registry" database
curl -X PUT $COUCH/registry
# create sample npm user
curl -X PUT $COUCH/_users/org.couchdb.user:integration -H Content-Type:application/json --data-binary '{"_id": "org.couchdb.user:integration","name": "integration","roles": [],"type": "user","password": "suchsecure","email": "integration@test.com"}'
# npm-registry-couchpp needs this variable set to run
export DEPLOY_VERSION=nope
# setup npm-registry-couchapp
npm explore npm-registry-couchapp -- npm start --npm-registry-couchapp:couch=$COUCH/registry
npm explore npm-registry-couchapp -- npm run load --npm-registry-couchapp:couch=$COUCH/registry
npm explore npm-registry-couchapp -- NO_PROMPT=yes npm run copy --npm-registry-couchapp:couch=$COUCH/registry
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# delete "registry" database
curl -X DELETE http://admin:password@127.0.0.1:5984/registry
# delete "_users" database
curl -X DELETE http://admin:password@127.0.0.1:5984/_users
# close couchdb background process
couchdb -d