X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=blobdiff_plain;f=docker%2Ftest_vminstall.bats;fp=docker%2Ftest_vminstall.bats;h=95254b43387316a7a55581bc4592e21a8423e0c0;hp=0000000000000000000000000000000000000000;hb=1239389195ada5f51435dc8d8476a71b88090092;hpb=395bf715f912ba18fefcd50795a0ff0e10d8dbb4 diff --git a/docker/test_vminstall.bats b/docker/test_vminstall.bats new file mode 100644 index 0000000..95254b4 --- /dev/null +++ b/docker/test_vminstall.bats @@ -0,0 +1,39 @@ +#!/usr/bin/env bats + +mountpath="/mnt" +image="/srv/debian.img" + +setup() { + if ! mountpoint "${mountpath}" &>/dev/null ; then + partition="$(kpartx -asv ${image} | awk '/add/ {print $3}')" + mount "/dev/mapper/${partition}" "${mountpath}" + fi +} + +teardown() { + if mountpoint "${mountpath}" &>/dev/null ; then + umount "${mountpath}" + kpartx -vd "${image}" + fi +} + +@test "ensure grub configuration is present" { + run ls "${mountpath}"/boot/grub/grub.cfg + [ "$status" -eq 0 ] +} + +@test "ensure eatmydata package is present" { + run chroot "${mountpath}" dpkg --list eatmydata + [ "$status" -eq 0 ] +} + +@test "kernel is present" { + run ls "${mountpath}"/boot/vmlinuz-* + [ "$status" -eq 0 ] +} + +@test "debian_version exists and is valid version" { + run cat "${mountpath}/etc/debian_version" + [ "$status" -eq 0 ] + [[ "$output" == [0-9].[0-9]* ]] || [[ "$output" == 'stretch/sid' ]] +}