tests: clean up the test containers

This commit is contained in:
Natanael Copa committed 2019-03-06 20:55:42 +01:00
1 parent 409d1f0fc5
commit c60c4fe2c9
1 file changed
+10 -9
+10 -9
View File
@@ -12,24 +12,24 @@ setup() {
case $BRANCH in
edge) skip;;
esac
run docker run alpine:$TAG sh -c '. ./etc/os-release; echo ${VERSION_ID%.*}'
run docker run --rm alpine:$TAG sh -c '. ./etc/os-release; echo ${VERSION_ID%.*}'
[ $status -eq 0 ]
[ "${lines[0]}" = "$VER" ]
}
@test "package installs cleanly" {
run docker run alpine:$TAG apk add --no-cache bash
run docker run --rm alpine:$TAG apk add --no-cache bash
[ $status -eq 0 ]
}
@test "timezone" {
run docker run alpine:$TAG date +%Z
run docker run --rm alpine:$TAG date +%Z
[ $status -eq 0 ]
[ "$output" = "UTC" ]
}
@test "repository list is correct" {
run docker run alpine:$TAG cat /etc/apk/repositories
run docker run --rm alpine:$TAG cat /etc/apk/repositories
[ $status -eq 0 ]
[ "${lines[0]}" = "http://dl-cdn.alpinelinux.org/alpine/$BRANCH/main" ]
[ "${lines[1]}" = "http://dl-cdn.alpinelinux.org/alpine/$BRANCH/community" ]
@@ -37,25 +37,26 @@ setup() {
}
@test "cache is empty" {
run docker run alpine:$TAG sh -c "ls -1 /var/cache/apk | wc -l"
run docker run --rm alpine:$TAG sh -c "ls -1 /var/cache/apk | wc -l"
[ $status -eq 0 ]
[ "$output" = "0" ]
}
@test "root password is disabled with default su" {
run docker run --user nobody alpine:$TAG su
run docker run --rm --user nobody alpine:$TAG su
[ $status -eq 1 ]
}
@test "root login is disabled" {
run docker run alpine:$TAG awk -F: '$1=="root"{print $2}' /etc/shadow
run docker run --rm alpine:$TAG awk -F: '$1=="root"{print $2}' /etc/shadow
[ $status -eq 0 ]
[ "$output" = "!" ]
}
@test "/dev/null should be missing" {
run sh -c "docker export $(docker create alpine:$TAG) | tar -t dev/null"
[ "$output" != "dev/null" ]
container=$(docker create alpine:$TAG)
run sh -c "docker export $container | tar -t dev/null"
[ $status -ne 0 ]
docker rm $container
}