Skip to content

Commit

Permalink
Merge pull request #216 from platanus/test-env-teardown
Browse files Browse the repository at this point in the history
Test env teardown
  • Loading branch information
difernandez authored Aug 2, 2019
2 parents 8e2a9db + 07de3d2 commit b8caac9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lib/potassium/assets/bin/cibuild.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ build(){
# Wait services to be ready
wait_services(){
function test_service {
docker-compose $DOCKER_COMPOSE_ARGS run test sh -c "nc -z $1 $2"
docker-compose $DOCKER_COMPOSE_ARGS run --rm test sh -c "nc -z $1 $2"
}

count=0
Expand All @@ -41,16 +41,16 @@ wait_services(){

# Prepare dependencies
dependencies(){
docker-compose $DOCKER_COMPOSE_ARGS run test bundle install
docker-compose $DOCKER_COMPOSE_ARGS run --rm test bundle install
}

assets() {
docker-compose $DOCKER_COMPOSE_ARGS run test /bin/bash -c "bin/setup && bundle exec rake assets:precompile"
docker-compose $DOCKER_COMPOSE_ARGS run --rm test /bin/bash -c "bin/setup && bundle exec rake assets:precompile"
}

# Prepare database
database(){
docker-compose $DOCKER_COMPOSE_ARGS run test bundle exec rake db:create db:schema:load
docker-compose $DOCKER_COMPOSE_ARGS run --rm test bundle exec rake db:create db:schema:load
}

# Run the specs
Expand All @@ -59,7 +59,7 @@ tests(){
RSPEC_JUNIT_ARGS="-r rspec_junit_formatter --format RspecJunitFormatter -o $HOME/.rspec_reports/junit.xml"
RSPEC_FORMAT_ARGS="--format progress --no-color"
}
docker-compose $DOCKER_COMPOSE_ARGS run test bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
docker-compose $DOCKER_COMPOSE_ARGS run --rm test bundle exec rspec spec $RSPEC_FORMAT_ARGS $RSPEC_JUNIT_ARGS
}

# Run the complete ci build
Expand Down
4 changes: 0 additions & 4 deletions spec/features/database_container_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
create_dummy_project("database" => database)
end

after do
`docker-compose -f #{project_path}/docker-compose.yml down`
end

[:postgresql, :mysql].each do |db_type|
context "when database is #{db_type}" do
let!(:database) { db_type }
Expand Down
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
create_tmp_directory
end

config.after(:each) do
docker_cleanup
end

config.before(:each) do
FakeGithub.clear!
FakeHeroku.clear!
Expand Down
4 changes: 4 additions & 0 deletions spec/support/potassium_test_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def on_project(&block)
end
end

def docker_cleanup
run_command(`docker-compose -f #{project_path}/docker-compose.yml down --volumes`)
end

private

def tmp_path
Expand Down

0 comments on commit b8caac9

Please sign in to comment.