From 32c1dcf75b2eb77863aaaadb606213f65dc432b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6nnemann?= Date: Thu, 9 Jul 2015 01:28:17 +0200 Subject: [PATCH] test(registry): lib to start and stop an npm-registry-couchapp --- .gitignore | 1 + package.json | 1 + test/registry/index.js | 12 ++++++++++++ test/registry/local.ini | 16 ++++++++++++++++ test/registry/start.sh | 25 +++++++++++++++++++++++++ test/registry/stop.sh | 10 ++++++++++ 6 files changed, 65 insertions(+) create mode 100644 test/registry/index.js create mode 100644 test/registry/local.ini create mode 100755 test/registry/start.sh create mode 100755 test/registry/stop.sh diff --git a/.gitignore b/.gitignore index 691b58d7..8115b829 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ node_modules # build-artifacts dist +test/registry/couchdb.* diff --git a/package.json b/package.json index 519c4f09..ccecdb52 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "mkdirp": "^0.5.1", "nock": "^2.5.0", "nyc": "^2.3.0", + "npm-registry-couchapp": "^2.6.11", "proxyquire": "^1.5.0", "rimraf": "^2.4.0", "standard": "^4.2.1", diff --git a/test/registry/index.js b/test/registry/index.js new file mode 100644 index 00000000..27d076aa --- /dev/null +++ b/test/registry/index.js @@ -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/' +} diff --git a/test/registry/local.ini b/test/registry/local.ini new file mode 100644 index 00000000..c9ffa267 --- /dev/null +++ b/test/registry/local.ini @@ -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 diff --git a/test/registry/start.sh b/test/registry/start.sh new file mode 100755 index 00000000..3dbc9145 --- /dev/null +++ b/test/registry/start.sh @@ -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 diff --git a/test/registry/stop.sh b/test/registry/stop.sh new file mode 100755 index 00000000..d8ccd2a4 --- /dev/null +++ b/test/registry/stop.sh @@ -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