diff --git a/.gitignore b/.gitignore index 1da718e6..fe8a26a0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.swp luet +tests/integration/shunit2 +tests/integration/bin \ No newline at end of file diff --git a/Makefile b/Makefile index b167b5a2..a91a54b1 100644 --- a/Makefile +++ b/Makefile @@ -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: diff --git a/tests/integration/01_simple.sh b/tests/integration/01_simple.sh new file mode 100755 index 00000000..37ba36a0 --- /dev/null +++ b/tests/integration/01_simple.sh @@ -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 < $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 + diff --git a/tests/integration/run.sh b/tests/integration/run.sh new file mode 100755 index 00000000..070e23b8 --- /dev/null +++ b/tests/integration/run.sh @@ -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" +