luet/tests/integration/01_simple.sh

101 lines
2.9 KiB
Bash
Raw Normal View History

2019-12-31 14:22:11 +00:00
#!/bin/bash
2019-12-31 14:56:03 +00:00
2019-12-31 14:22:11 +00:00
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 > /dev/null
2019-12-31 14:22:11 +00:00
buildst=$?
assertEquals 'builds successfully' "$buildst" "0"
2019-12-31 14:56:03 +00:00
assertTrue 'create package dep B' "[ -e '$tmpdir/testbuild/b-test-1.0.package.tar.gz' ]"
assertTrue 'create package' "[ -e '$tmpdir/testbuild/c-test-1.0.package.tar.gz' ]"
2019-12-31 14:22:11 +00:00
}
testRepo() {
2019-12-31 14:56:03 +00:00
assertTrue 'no repository' "[ ! -e '$tmpdir/testbuild/repository.yaml' ]"
2019-12-31 14:22:11 +00:00
luet create-repo --tree "$ROOT_DIR/tests/fixtures/buildableseed" \
--output $tmpdir/testbuild \
--packages $tmpdir/testbuild \
--name "test" \
2020-01-01 09:47:31 +00:00
--descr "Test Repo" \
--urls $tmpdir/testrootfs \
--type disk > /dev/null
2019-12-31 14:22:11 +00:00
createst=$?
assertEquals 'create repo successfully' "$createst" "0"
2019-12-31 14:56:03 +00:00
assertTrue 'create repository' "[ -e '$tmpdir/testbuild/repository.yaml' ]"
2019-12-31 14:22:11 +00:00
}
2020-01-01 09:47:31 +00:00
testConfig() {
2019-12-31 14:22:11 +00:00
mkdir $tmpdir/testrootfs
2020-01-01 09:47:31 +00:00
cat <<EOF > $tmpdir/luet.yaml
general:
debug: true
system:
rootfs: $tmpdir/testrootfs
database_path: "/"
database_engine: "boltdb"
config_from_host: true
2020-01-01 09:47:31 +00:00
repositories:
- name: "main"
type: "disk"
enable: true
urls:
- "$tmpdir/testbuild"
2019-12-31 14:22:11 +00:00
EOF
2020-01-01 09:47:31 +00:00
luet config --config $tmpdir/luet.yaml
res=$?
assertEquals 'config test successfully' "$res" "0"
}
testInstall() {
2020-11-22 19:16:04 +00:00
luet install -y --config $tmpdir/luet.yaml test/c
2020-11-29 11:02:46 +00:00
#luet install -y --config $tmpdir/luet.yaml test/c@1.0 > /dev/null
2019-12-31 14:22:11 +00:00
installst=$?
assertEquals 'install test successfully' "$installst" "0"
2019-12-31 14:56:03 +00:00
assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
2019-12-31 14:22:11 +00:00
}
testReInstall() {
2020-11-29 11:02:46 +00:00
output=$(luet install -y --config $tmpdir/luet.yaml test/c@1.0)
echo "$output"
installst=$?
assertEquals 'install test successfully' "$installst" "0"
2020-11-22 19:16:04 +00:00
assertContains 'contains warning' "$output" 'No packages to install'
}
2019-12-31 14:56:03 +00:00
testUnInstall() {
2020-11-22 19:16:04 +00:00
luet uninstall -y --config $tmpdir/luet.yaml test/c
2019-12-31 14:56:03 +00:00
installst=$?
assertEquals 'uninstall test successfully' "$installst" "0"
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
}
2019-12-31 14:22:11 +00:00
testInstallAgain() {
assertTrue 'package uninstalled' "[ ! -e '$tmpdir/testrootfs/c' ]"
2020-11-29 11:02:46 +00:00
output=$(luet install -y --config $tmpdir/luet.yaml test/c@1.0)
installst=$?
assertEquals 'install test successfully' "$installst" "0"
2020-11-22 19:16:04 +00:00
assertNotContains 'contains warning' "$output" 'No packages to install'
assertTrue 'package installed' "[ -e '$tmpdir/testrootfs/c' ]"
2020-02-02 09:38:41 +00:00
}
testCleanup() {
luet cleanup --config $tmpdir/luet.yaml
installst=$?
assertEquals 'install test successfully' "$installst" "0"
assertTrue 'package installed' "[ ! -e '$tmpdir/testrootfs/packages/c-test-1.0.package.tar.gz' ]"
}
2019-12-31 14:22:11 +00:00
# Load shUnit2.
. "$ROOT_DIR/tests/integration/shunit2"/shunit2