diff --git a/test/00-simple.bats b/test/00-simple.bats index 38196b9..dceb03a 100644 --- a/test/00-simple.bats +++ b/test/00-simple.bats @@ -1,23 +1,31 @@ #!/usr/bin/env bats -t +load helpers + @test "Help" { - run $CTR_ENGINE run --rm $CTR_IMAGE -h + run_ctr $CTR_IMAGE -h [ "$status" -eq 0 ] [[ ${lines[0]} =~ "BuildSourceImage.sh version " ]] [[ ${lines[1]} =~ "Usage: BuildSourceImage.sh " ]] } @test "Version" { - run $CTR_ENGINE run --rm $CTR_IMAGE -v + run_ctr $CTR_IMAGE -v [ "$status" -eq 0 ] [[ ${lines[0]} =~ "BuildSourceImage.sh version " ]] } @test "List Drivers" { - run $CTR_ENGINE run --rm $CTR_IMAGE -l + run_ctr $CTR_IMAGE -l [ "$status" -eq 0 ] [[ ${lines[0]} =~ "sourcedriver_context_dir" ]] [[ ${lines[1]} =~ "sourcedriver_extra_src_dir" ]] [[ ${lines[2]} =~ "sourcedriver_rpm_dir" ]] [[ ${lines[3]} =~ "sourcedriver_rpm_fetch" ]] } + +@test "No input" { + run_ctr $CTR_IMAGE + [ "$status" -eq 1 ] + [[ ${lines[0]} =~ "[SrcImg][ERROR] provide an input (example: BuildSourceImage.sh -i docker.io/centos -e ./my-sources/ )" ]] +} diff --git a/test/01-from_rpms.bats b/test/01-from_rpms.bats index 2f44779..7533012 100644 --- a/test/01-from_rpms.bats +++ b/test/01-from_rpms.bats @@ -1,8 +1,10 @@ #!/usr/bin/env bats -t +load helpers + @test "build from RPMS" { d=$(mktemp -d) - run $CTR_ENGINE run --rm -v $(pwd)/.testprep/srpms/:/src:ro -v ${d}:/output/ $CTR_IMAGE -s /src + run_ctr -v $(pwd)/.testprep/srpms/:/src:ro -v ${d}:/output/ $CTR_IMAGE -s /src [ "$status" -eq 0 ] #echo ${lines[@]} [[ ${lines[0]} =~ "[SrcImg][INFO] calling source collection drivers" ]] diff --git a/test/helpers.bash b/test/helpers.bash new file mode 100644 index 0000000..67428d9 --- /dev/null +++ b/test/helpers.bash @@ -0,0 +1,3 @@ +function run_ctr() { + run $CTR_ENGINE run --security-opt label=disable --rm "$@" +}