Add integration tests

This commit is contained in:
Ettore Di Giacinto 2019-12-31 15:22:11 +01:00
parent efdfe72568
commit 62ebe1a82b
No known key found for this signature in database
GPG Key ID: 1ADA699B145A2D1C
4 changed files with 71 additions and 0 deletions

2
.gitignore vendored
View File

@ -1,2 +1,4 @@
*.swp
luet
tests/integration/shunit2
tests/integration/bin

View File

@ -21,6 +21,10 @@ test:
GO111MODULE=off go get github.com/onsi/gomega/...
ginkgo -race -r ./...
.PHONY: test-integration
test-integration:
tests/integration/run.sh
.PHONY: coverage
coverage:
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
@ -36,6 +40,8 @@ help:
.PHONY: clean
clean:
rm -rf release/
rm -rf tests/integration/shunit2
rm -rf tests/integration/bin
.PHONY: deps
deps:

48
tests/integration/01_simple.sh Executable file
View File

@ -0,0 +1,48 @@
#!/bin/bash
set -e
export LUET_NOLOCK=true
oneTimeSetUp() {
export tmpdir="$(mktemp -d)"
}
oneTimeTearDown() {
rm -rf "$tmpdir"
}
testBuild() {
mkdir $tmpdir/testbuild
luet build --tree "$ROOT_DIR/tests/fixtures/buildableseed" --destination $tmpdir/testbuild --compression gzip test/c-1.0
buildst=$?
assertEquals 'builds successfully' "$buildst" "0"
}
testRepo() {
luet create-repo --tree "$ROOT_DIR/tests/fixtures/buildableseed" \
--output $tmpdir/testbuild \
--packages $tmpdir/testbuild \
--name "test" \
--uri $tmpdir/testrootfs \
--type local
createst=$?
assertEquals 'create repo successfully' "$createst" "0"
}
testInstall() {
mkdir $tmpdir/testrootfs
cat <<EOF > $tmpdir/luet.yaml
system-repositories:
- name: "main"
type: "local"
uri: "$tmpdir/testbuild"
EOF
luet install --config $tmpdir/luet.yaml --system-dbpath $tmpdir/testrootfs --system-target $tmpdir/testrootfs test/c-1.0
installst=$?
assertEquals 'install test successfully' "$installst" "0"
}
# Load shUnit2.
. "$ROOT_DIR/tests/integration/shunit2"/shunit2

15
tests/integration/run.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
set -e
export ROOT_DIR="$(git rev-parse --show-toplevel)"
pushd $ROOT_DIR
go build -o "$ROOT_DIR/tests/integration/bin/luet"
popd
[ ! -d "$ROOT_DIR/tests/integration/shunit2" ] && git clone https://github.com/kward/shunit2.git "$ROOT_DIR/tests/integration/shunit2"
export PATH=$ROOT_DIR/tests/integration/bin/:$PATH
"$ROOT_DIR/tests/integration/01_simple.sh"