Implement some initial sanity checks using Bats
Somehow related to GH-1
This commit is contained in:
parent
92b36edee9
commit
8efb8daf07
6 changed files with 98 additions and 0 deletions
|
@ -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
|
7
spec/acceptance/fixtures/auto-detect.rb
Normal file
7
spec/acceptance/fixtures/auto-detect.rb
Normal 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
|
5
spec/acceptance/fixtures/no-cachier-simple.rb
Normal file
5
spec/acceptance/fixtures/no-cachier-simple.rb
Normal 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
|
6
spec/acceptance/fixtures/no-cachier-with-provisioning.rb
Normal file
6
spec/acceptance/fixtures/no-cachier-with-provisioning.rb
Normal 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
|
45
spec/acceptance/sanity_check.bats
Normal file
45
spec/acceptance/sanity_check.bats
Normal 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
|
||||||
|
}
|
26
spec/acceptance/test_helper.bash
Normal file
26
spec/acceptance/test_helper.bash
Normal 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
|
||||||
|
}
|
Loading…
Reference in a new issue