aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMoritz Meißelbach <m.meisselbach@inpsyde.com>2019-11-29 21:28:24 +0100
committerMoritz Meißelbach <m.meisselbach@inpsyde.com>2019-11-29 21:28:24 +0100
commit3835562c5325c279809bb41c34c6afca6288a1cb (patch)
tree7bbf1910d43d9a512146bc5a4cb11842e66bf0d3 /tests
parent22182d980a2ebde89fe2970e11c39fbf8e4d6628 (diff)
downloadsway-launcher-desktop-3835562c5325c279809bb41c34c6afca6288a1cb.tar.gz
sway-launcher-desktop-3835562c5325c279809bb41c34c6afca6288a1cb.zip
[WIP] Read custom providers from a ~/.config/sway-launcher-desktop/providers.conf file.
Diffstat (limited to 'tests')
-rw-r--r--tests/data/config/0/sway-launcher-desktop/providers.conf7
-rw-r--r--tests/describe.bats6
-rw-r--r--tests/providers.bats36
3 files changed, 46 insertions, 3 deletions
diff --git a/tests/data/config/0/sway-launcher-desktop/providers.conf b/tests/data/config/0/sway-launcher-desktop/providers.conf
new file mode 100644
index 0000000..4e82b2b
--- /dev/null
+++ b/tests/data/config/0/sway-launcher-desktop/providers.conf
@@ -0,0 +1,7 @@
+[foo]
+list_cmd=printf "foo\034foo"
+launch_cmd=printf 'printf "{1}"'
+preview_cmd=printf 'printf "{1}"'
+
+[incomplete]
+list_cmd=echo 'nope'
diff --git a/tests/describe.bats b/tests/describe.bats
index d02ee96..1541974 100644
--- a/tests/describe.bats
+++ b/tests/describe.bats
@@ -1,13 +1,13 @@
@test "Name and description of firefox desktop file are properly extracted" {
- run ../sway-launcher-desktop.sh describe data/desktop-files/0/applications/firefox.desktop desktop
+ run env XDG_CONFIG_HOME=./data/config ../sway-launcher-desktop.sh describe desktop ./data/desktop-files/0/applications/firefox.desktop
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "Firefox" ]]
[[ ${lines[1]} =~ "Browse the World Wide Web" ]]
}
@test "Name and description of ls command should be given" {
- run ../sway-launcher-desktop.sh describe ls command
+ run env XDG_CONFIG_HOME=./data/config ../sway-launcher-desktop.sh describe command ls
[ "$status" -eq 0 ]
[[ ${lines[0]} =~ "ls" ]]
[[ ${lines[1]} =~ "list directory contents" ]]
-} \ No newline at end of file
+}
diff --git a/tests/providers.bats b/tests/providers.bats
new file mode 100644
index 0000000..1c11f0d
--- /dev/null
+++ b/tests/providers.bats
@@ -0,0 +1,36 @@
+@test "Builtin desktop provider works" {
+ run env XDG_CONFIG_HOME=./data/config XDG_DATA_HOME=./data/desktop-files/1 XDG_DATA_DIRS=./data/desktop-files/0 ../sway-launcher-desktop.sh provide desktop
+ echo "OUTPUT:$output"
+ echo "LINES:${#lines[@]}"
+ [ "$status" -eq 0 ]
+ [[ ${#lines[@]} -gt 2 ]]
+}
+
+@test "Builtin command provider works" {
+ run env XDG_CONFIG_HOME=./data/config XDG_DATA_HOME=./data/desktop-files/1 XDG_DATA_DIRS=./data/desktop-files/0 ../sway-launcher-desktop.sh provide command
+ echo "OUTPUT:$output"
+ echo "LINES:${#lines[@]}"
+ [ "$status" -eq 0 ]
+ [[ ${#lines[@]} -gt 2 ]]
+}
+
+@test "Reads custom provider from providers.conf" {
+ run printf %q "$(env XDG_CONFIG_HOME=./data/config/0 ../sway-launcher-desktop.sh provide foo)"
+ echo "OUTPUT:$output"
+ [ "$status" -eq 0 ]
+ [[ ${output} == "$'foo\034foo'" ]]
+}
+
+@test "Skips incomplete custom provider from providers.conf" {
+ run printf %q "$(env XDG_CONFIG_HOME=./data/config/0 ../sway-launcher-desktop.sh provide incomplete)"
+ echo "OUTPUT:$output"
+ [ "$status" -eq 0 ]
+ [[ ${output} == "''" ]]
+}
+
+@test "Does not use builtin providers when reading from providers.conf" {
+ run printf %q "$(env XDG_CONFIG_HOME=./data/config/0 ../sway-launcher-desktop.sh provide desktop)"
+ echo "OUTPUT:$output"
+ [ "$status" -eq 0 ]
+ [[ ${output} == "''" ]]
+}