Implement some initial sanity checks using Bats

Somehow related to GH-1
This commit is contained in:
Fabio Rehm 2013-08-13 22:39:32 -03:00
parent 92b36edee9
commit 8efb8daf07
6 changed files with 98 additions and 0 deletions

View File

@ -0,0 +1,9 @@
Vagrant.require_plugin 'vagrant-cachier'
Vagrant.require_plugin 'vagrant-lxc'
Vagrant.configure("2") do |config|
config.cache.auto_detect = true
config.cache.scope = :machine
config.vm.box = 'raring64'
config.vm.provision :shell, inline: 'apt-get update && apt-get install -y git'
end

View File

@ -0,0 +1,7 @@
Vagrant.require_plugin 'vagrant-cachier'
Vagrant.require_plugin 'vagrant-lxc'
Vagrant.configure("2") do |config|
config.cache.auto_detect = true
config.vm.box = 'quantal64'
config.vm.provision :shell, inline: 'echo Hello!'
end

View File

@ -0,0 +1,5 @@
Vagrant.require_plugin 'vagrant-cachier'
Vagrant.require_plugin 'vagrant-lxc'
Vagrant.configure("2") do |config|
config.vm.box = 'quantal64'
end

View File

@ -0,0 +1,6 @@
Vagrant.require_plugin 'vagrant-cachier'
Vagrant.require_plugin 'vagrant-lxc'
Vagrant.configure("2") do |config|
config.vm.box = 'quantal64'
config.vm.provision :shell, inline: 'echo Hello!'
end

View File

@ -0,0 +1,45 @@
#!/usr/bin/env bats
load test_helper
@test "Vagrantfile without cachier statement does not blow up when bringing the VM up" {
configure_env "no-cachier-simple.rb"
vagrant_up
[ "$status" -eq 0 ]
vagrant_destroy
configure_env "no-cachier-with-provisioning.rb"
vagrant_up
[ "$status" -eq 0 ]
vagrant_destroy
}
@test "Vagrantfile with cachier auto_detect statement does not blow up when bringing the VM up" {
configure_env "auto-detect.rb"
vagrant_up
[ "$status" -eq 0 ]
vagrant_destroy
}
@test "APT cache bucket configures the cache dir properly and keeps cache dir around" {
configure_env "auto-detect-with-provisioning.rb"
# Make sure cache dir does not exist
test ! -d tmp/.vagrant/machines/default/cache/apt
vagrant_up
[ "$status" -eq 0 ]
# Make sure packages are being cached
test -d tmp/.vagrant/machines/default/cache/apt
FILES=(`ls tmp/.vagrant/machines/default/cache/apt/git*.deb`)
[ ${#FILES[@]} -gt 0 ]
vagrant_destroy
# Make sure packages are not removed between machine rebuilds
FILES=(`ls tmp/.vagrant/machines/default/cache/apt/git*.deb`)
[ ${#FILES[@]} -gt 0 ]
empty_cache
}

View File

@ -0,0 +1,26 @@
vagrant_up() {
pushd tmp
run bundle exec vagrant up > /tmp/vagrant-cachier-tests.log
popd
}
vagrant_destroy() {
pushd tmp
run bundle exec vagrant destroy -f
popd
}
configure_env() {
fixture=$1
mkdir -p tmp/
cp spec/acceptance/fixtures/${fixture} tmp/Vagrantfile
vagrant_destroy
[ "$status" -eq 0 ]
rm -rf tmp/.vagrant
}
empty_cache() {
rm -rf tmp/.vagrant/cache
}