summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2016-05-02 10:47:59 +0200
committerAlexander Larsson <alexl@redhat.com>2016-05-02 10:47:59 +0200
commit123f32015dd852ea788ea699accef1331dc8fa56 (patch)
tree75d9cffe3f9845fd72c51fe6d724279101c573d9 /tests
parent2f465215e23f956419b9ae905ae3c94717bc2de1 (diff)
downloadxdg-app-123f32015dd852ea788ea699accef1331dc8fa56.tar.gz
tests/test-run.sh: Add tests for proper installation
Diffstat (limited to 'tests')
-rw-r--r--tests/libtest.sh19
-rwxr-xr-xtests/make-test-app.sh14
-rwxr-xr-xtests/test-run.sh31
3 files changed, 63 insertions, 1 deletions
diff --git a/tests/libtest.sh b/tests/libtest.sh
index a440835..caae1dd 100644
--- a/tests/libtest.sh
+++ b/tests/libtest.sh
@@ -72,6 +72,9 @@ TEST_DATA_DIR=`mktemp -d /var/tmp/test-xdg-app-XXXXXX`
export XDG_DATA_HOME=${TEST_DATA_DIR}/share
+export USERDIR=${TEST_DATA_DIR}/share/xdg-app
+export ARCH=`xdg-app --default-arch`
+
export XDG_APP="${CMD_PREFIX} xdg-app"
assert_streq () {
@@ -86,6 +89,10 @@ assert_has_file () {
test -f "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1)
}
+assert_has_symlink () {
+ test -L "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1)
+}
+
assert_has_dir () {
test -d "$1" || (echo 1>&2 "Couldn't find '$1'"; exit 1)
}
@@ -120,6 +127,14 @@ assert_file_has_content () {
fi
}
+assert_symlink_has_content () {
+ if ! readlink "$1" | grep -q -e "$2"; then
+ readlink "$1" |sed -e 's/^/# /' >&2
+ echo 1>&2 "Symlink '$1' doesn't match regexp '$2'"
+ exit 1
+ fi
+}
+
assert_file_empty() {
if test -s "$1"; then
sed -e 's/^/# /' < "$1" >&2
@@ -144,6 +159,10 @@ run () {
}
+run_sh () {
+ ${CMD_PREFIX} xdg-app run --command=bash org.test.Hello -c "$*"
+}
+
sed s#@testdir@#${test_builddir}# ${test_srcdir}/session.conf.in > session.conf
eval `dbus-launch --config-file=session.conf --sh-syntax`
diff --git a/tests/make-test-app.sh b/tests/make-test-app.sh
index b5bce5a..20683e4 100755
--- a/tests/make-test-app.sh
+++ b/tests/make-test-app.sh
@@ -14,6 +14,20 @@ echo "Hello world, from a sandbox"
EOF
chmod a+x ${DIR}/files/bin/hello.sh
+mkdir -p ${DIR}/files/share/applications
+cat > ${DIR}/files/share/applications/org.test.Hello.desktop <<EOF
+[Desktop Entry]
+Version=1.0
+Type=Application
+Exec=hello.sh
+Icon=org.test.Hello
+MimeType=x-test/Hello
+EOF
+
+mkdir -p ${DIR}/files/share/icons/hicolor/64x64/apps
+cp $(dirname $0)/org.test.Hello.png ${DIR}/files/share/icons/hicolor/64x64/apps/
+
+
mkdir -p ${DIR}/files/share/app-info/xmls
mkdir -p ${DIR}/files/share/app-info/icons/xdg-app/64x64
gzip -c > ${DIR}/files/share/app-info/xmls/org.test.Hello.xml.gz <<EOF
diff --git a/tests/test-run.sh b/tests/test-run.sh
index 328be2e..836b2fe 100755
--- a/tests/test-run.sh
+++ b/tests/test-run.sh
@@ -21,12 +21,41 @@ set -euo pipefail
. $(dirname $0)/libtest.sh
-echo "1..1"
+echo "1..3"
setup_repo
install_repo
+# Verify that app is correctly installed
+
+assert_has_dir $USERDIR/app/org.test.Hello
+assert_has_symlink $USERDIR/app/org.test.Hello/current
+assert_symlink_has_content $USERDIR/app/org.test.Hello/current ^$ARCH/master$
+assert_has_dir $USERDIR/app/org.test.Hello/$ARCH/master
+assert_has_symlink $USERDIR/app/org.test.Hello/$ARCH/master/active
+assert_has_file $USERDIR/app/org.test.Hello/$ARCH/master/active/deploy
+assert_has_file $USERDIR/app/org.test.Hello/$ARCH/master/active/metadata
+assert_has_dir $USERDIR/app/org.test.Hello/$ARCH/master/active/files
+assert_has_dir $USERDIR/app/org.test.Hello/$ARCH/master/active/export
+assert_has_file $USERDIR/exports/share/applications/org.test.Hello.desktop
+# Ensure Exec key is rewritten
+assert_file_has_content $USERDIR/exports/share/applications/org.test.Hello.desktop "^Exec=.*/xdg-app run --branch=master --arch=$ARCH --command=hello.sh org.test.Hello$"
+assert_has_file $USERDIR/exports/share/icons/hicolor/64x64/apps/org.test.Hello.png
+
+# Ensure triggers ran
+assert_has_file $USERDIR/exports/share/applications/mimeinfo.cache
+assert_file_has_content $USERDIR/exports/share/applications/mimeinfo.cache x-test/Hello
+assert_has_file $USERDIR/exports/share/icons/hicolor/icon-theme.cache
+assert_has_file $USERDIR/exports/share/icons/hicolor/index.theme
+
+echo "ok install"
+
run org.test.Hello > hello_out
assert_file_has_content hello_out '^Hello world, from a sandbox$'
echo "ok hello"
+
+run_sh cat /run/user/`id -u`/xdg-app-info > xai
+assert_file_has_content xai '^name=org.test.Hello$'
+
+echo "ok xdg-app-info"