Merge pull request #31 from vrothberg/helpers
test: add helpers.bash to reduce boilerplate
This commit is contained in:
commit
83159669c4
3 changed files with 17 additions and 4 deletions
|
@ -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/ )" ]]
|
||||
}
|
||||
|
|
|
@ -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" ]]
|
||||
|
|
3
test/helpers.bash
Normal file
3
test/helpers.bash
Normal file
|
@ -0,0 +1,3 @@
|
|||
function run_ctr() {
|
||||
run $CTR_ENGINE run --security-opt label=disable --rm "$@"
|
||||
}
|
Loading…
Reference in a new issue