Merge pull request #24 from vrothberg/add-integration-tests
add simple integration tests
This commit is contained in:
commit
ba7191aed9
3 changed files with 44 additions and 4 deletions
11
.travis.yml
11
.travis.yml
|
@ -1,10 +1,17 @@
|
|||
sudo: required
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
env:
|
||||
- CTR_ENGINE=docker
|
||||
|
||||
before_install:
|
||||
- sudo add-apt-repository ppa:projectatomic/ppa --yes
|
||||
- sudo add-apt-repository ppa:duggan/bats --yes
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install -qq podman shellcheck skopeo
|
||||
- sudo apt-get install -qq bats shellcheck
|
||||
|
||||
script:
|
||||
- make validate
|
||||
- make build-container
|
||||
- make test-integration
|
||||
|
|
13
Makefile
13
Makefile
|
@ -1,12 +1,21 @@
|
|||
SRC := ./BuildSourceImage.sh
|
||||
CTR_IMAGE := localhost/containers/buildsourceimage
|
||||
CTR_ENGINE ?= podman
|
||||
|
||||
all: validate
|
||||
|
||||
.PHONY: validate
|
||||
validate: $(SRC)
|
||||
shellcheck -a $(SRC)
|
||||
shellcheck $(SRC)
|
||||
|
||||
.PHONY: build-container
|
||||
build-container: Dockerfile
|
||||
podman build -f Dockerfile -t $(CTR_IMAGE) .
|
||||
@echo
|
||||
@echo "Building BuildSourceImage Container"
|
||||
$(CTR_ENGINE) build --quiet --file Dockerfile --tag $(CTR_IMAGE) .
|
||||
|
||||
.PHONY: test-integration
|
||||
test-integration: build-container
|
||||
@echo
|
||||
@echo "Running integration tests"
|
||||
CTR_IMAGE=$(CTR_IMAGE) CTR_ENGINE=$(CTR_ENGINE) bats test/
|
||||
|
|
24
test/simple.bats
Normal file
24
test/simple.bats
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bats -t
|
||||
|
||||
@test "Help" {
|
||||
run $CTR_ENGINE run --rm $CTR_IMAGE -h
|
||||
[ "$status" -eq 1 ]
|
||||
#TODO: we should exit 0
|
||||
[[ ${lines[0]} =~ "BuildSourceImage.sh version " ]]
|
||||
[[ ${lines[1]} =~ "Usage: BuildSourceImage.sh " ]]
|
||||
}
|
||||
|
||||
@test "Version" {
|
||||
run $CTR_ENGINE run --rm $CTR_IMAGE -v
|
||||
[ "$status" -eq 0 ]
|
||||
[[ ${lines[0]} =~ "BuildSourceImage.sh version " ]]
|
||||
}
|
||||
|
||||
@test "List Drivers" {
|
||||
run $CTR_ENGINE run --rm $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" ]]
|
||||
}
|
Loading…
Reference in a new issue