Skip to content

Commit

Permalink
test(registry): lib to start and stop an npm-registry-couchapp
Browse files Browse the repository at this point in the history
  • Loading branch information
boennemann committed Jul 9, 2015
1 parent 4093bb2 commit 32c1dcf
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -9,3 +9,4 @@ node_modules

# build-artifacts
dist
test/registry/couchdb.*
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions 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/'
}
16 changes: 16 additions & 0 deletions 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
25 changes: 25 additions & 0 deletions 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
10 changes: 10 additions & 0 deletions 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

0 comments on commit 32c1dcf

Please sign in to comment.