mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #373 from plietar/tests-hooks
Allow tests to have a setup phase.
This commit is contained in:
1
tests/apps/config/Procfile
Normal file
1
tests/apps/config/Procfile
Normal file
@@ -0,0 +1 @@
|
||||
web: node web.js
|
||||
3
tests/apps/config/check_deploy
Executable file
3
tests/apps/config/check_deploy
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
set -e; output="$(curl -s $1)"; echo $output; test "$output" == "config-test"
|
||||
|
||||
11
tests/apps/config/package.json
Normal file
11
tests/apps/config/package.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "node-example",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"express": "2.5.x"
|
||||
},
|
||||
"engines": {
|
||||
"node": "0.8.x",
|
||||
"npm": "1.1.x"
|
||||
}
|
||||
}
|
||||
8
tests/apps/config/post-deploy
Executable file
8
tests/apps/config/post-deploy
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -ex;
|
||||
|
||||
REMOTE=$1
|
||||
REPO=$2
|
||||
|
||||
ssh $REMOTE config:set $REPO CONFTEST=config-test
|
||||
|
||||
12
tests/apps/config/web.js
Normal file
12
tests/apps/config/web.js
Normal file
@@ -0,0 +1,12 @@
|
||||
var express = require('express');
|
||||
|
||||
var app = express.createServer(express.logger());
|
||||
|
||||
app.get('/', function(request, response) {
|
||||
response.send(process.env.CONFTEST);
|
||||
});
|
||||
|
||||
var port = process.env.PORT || 5000;
|
||||
app.listen(port, function() {
|
||||
console.log("Listening on " + port);
|
||||
});
|
||||
@@ -1,6 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
set -exo pipefail
|
||||
SELF=`which $0`; APP="$1"; TARGET="$2"; FORWARDED_PORT="$3"
|
||||
REMOTE="dokku@$TARGET"
|
||||
REPO="test-$(basename $APP)-$RANDOM"
|
||||
|
||||
TMP=$(mktemp -d -t "$TARGET.XXXXX")
|
||||
trap "rm -rf $TMP" EXIT
|
||||
rmdir $TMP && cp -r $(dirname $SELF)/$APP $TMP
|
||||
@@ -8,14 +11,20 @@ cd $TMP
|
||||
git init
|
||||
git config user.email "robot@example.com"
|
||||
git config user.name "Test Robot"
|
||||
git remote add target $REMOTE:$REPO
|
||||
|
||||
[[ -f gitignore ]] && mv gitignore .gitignore
|
||||
git add .
|
||||
|
||||
[[ -x pre-commit ]] && ./pre-commit $REMOTE $REPO
|
||||
git commit -m 'initial commit'
|
||||
REPO="test-$(basename $APP)-$RANDOM"
|
||||
git remote add target dokku@$TARGET:$REPO
|
||||
git push target master
|
||||
URL=$(ssh dokku@$TARGET url $REPO)$FORWARDED_PORT
|
||||
[[ -x post-deploy ]] && ./post-deploy $REMOTE $REPO
|
||||
|
||||
URL=$(ssh $REMOTE url $REPO)$FORWARDED_PORT
|
||||
sleep 2
|
||||
./check_deploy $URL && echo "-----> Deploy success!" || {
|
||||
sleep 4
|
||||
./check_deploy $URL && echo "-----> Deploy success!"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user