Skip to content

Commit

Permalink
test(integration): make em at least run locally
Browse files Browse the repository at this point in the history
  • Loading branch information
boennemann committed Jul 19, 2015
1 parent 22a283a commit ddaec4f
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 22 deletions.
4 changes: 3 additions & 1 deletion .gitignore
@@ -1,12 +1,14 @@
# common
coverage
node_modules
test/registry/couch
test/registry/data
*.log
*.dump
.DS_Store
.nyc_output
.test
.tmp

# build-artifacts
dist
test/registry/couchdb.*
3 changes: 3 additions & 0 deletions .npmignore
@@ -1,7 +1,10 @@
# common
coverage
node_modules
test/registry/couch
test/registry/data
*.log
*.dump
.DS_Store
.nyc_output
.test
Expand Down
5 changes: 3 additions & 2 deletions test/lib/base-scenario.js
Expand Up @@ -6,8 +6,9 @@ module.exports = function (cwd, uri) {
.env('NPM_OLD_TOKEN', 'aW50ZWdyYXRpb246c3VjaHNlY3VyZQ==')
.env('NPM_EMAIL', 'integration@test.com')
.env('GH_TOKEN', 'ghtoken')
.env('CI', true)
.env('CI', 'true')
.env('TRAVIS', 'true')
.env('TRAVIS_BRANCH', 'master')
.env('npm_config_registry', uri)
.env('npm_config_loglevel', 'info')
.clone()
}
2 changes: 1 addition & 1 deletion test/registry/index.js
Expand Up @@ -8,5 +8,5 @@ const opts = {
module.exports = {
start: exec.bind(null, './start.sh', opts),
stop: exec.bind(null, './stop.sh', opts),
uri: 'http://localhost:5984/registry/_design/app/_rewrite/'
uri: 'http://localhost:15986/registry/_design/app/_rewrite/'
}
15 changes: 9 additions & 6 deletions test/registry/local.ini
@@ -1,16 +1,19 @@
[couchdb]
database_dir = data
view_index_dir = data
delayed_commits = false

[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
port = 15986
bind_address = 127.0.0.1
secure_rewrites = false

[couchdb]
delayed_commits = false
[log]
file = couch/couch.log

[admins]
admin = -pbkdf2-89582b49cd2e8443e29a841f5a76d367956a8e58,1afa2f1531a17ac97f2ac9e334293753,10

[log]
level = none
17 changes: 14 additions & 3 deletions test/registry/start.sh
Expand Up @@ -5,10 +5,21 @@ set -e

cd $(dirname $0)

# start couchdb as a background process, reset config, load local config
couchdb -b -a local.ini
mkdir -p couch

COUCH=http://admin:password@127.0.0.1:5984
# start couchdb as a background process, load local config, specify writable logfiles
if [[ $TRAVIS = true ]]
then
echo 'starting couch with sudo'
sudo couchdb -b -a local.ini -p couch/pid -o couch/stdout.log -e couch/stderr.log
else
couchdb -b -a local.ini -p couch/pid -o couch/stdout.log -e couch/stderr.log
fi

# wait for couch to start
sleep 5

COUCH=http://admin:password@127.0.0.1:15986

# create "registry" database
curl -X PUT $COUCH/registry
Expand Down
14 changes: 8 additions & 6 deletions test/registry/stop.sh
@@ -1,10 +1,12 @@
#!/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

# delete data and logs
cd $(dirname $0)

cat couch/{couch,stdout,stderr}.log

rm -rf couch
rm -rf data
15 changes: 12 additions & 3 deletions test/scenarios/pre.js
Expand Up @@ -12,16 +12,23 @@ test('change version', (t) => {

registry.start((err) => {
t.error(err, 'registry started')
if (err) t.bailout('registry not started')
if (err) {
t.end()
t.bailout('registry not started')
}

testModule('change-version', (err, cwd) => {
t.error(err, 'test-module created')
if (err) t.bailout('test-module not created')
if (err) {
t.end()
t.bailout('test-module not created')
}

t.test('no version', (tt) => {
tt.plan(1)

baseScenario(cwd, registry.uri)
.env('npm_config_loglevel', 'info')
.run('node ../../../bin/semantic-release.js pre')
.stderr(/ENOCHANGE/)
.code(1)
Expand Down Expand Up @@ -80,8 +87,10 @@ test('change version', (t) => {
})

tearDown(() => {
function cb (err) {
function cb (err, stdout, stderr) {
if (err) console.log(err)
if (stdout) console.log(stdout)
if (stderr) console.log(stderr)
}

rimraf(join(__dirname, '../tmp'), cb)
Expand Down

0 comments on commit ddaec4f

Please sign in to comment.