From 302bae9c5fb75665d8fefa001cfe101db4947ad9 Mon Sep 17 00:00:00 2001 From: John D Pell Date: Thu, 3 Feb 2022 13:53:54 -0800 Subject: [PATCH] test/battery: require matching battery identifier --- test/plugins/battery.plugin.bats | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/plugins/battery.plugin.bats b/test/plugins/battery.plugin.bats index 7ca962d9..f06fa008 100755 --- a/test/plugins/battery.plugin.bats +++ b/test/plugins/battery.plugin.bats @@ -194,15 +194,22 @@ function setup_acpi { # The passed in parameter is used for the remaining battery percentage. function setup_upower { percent="$1" + BAT0="/org/freedesktop/UPower/devices/battery_BAT$RANDOM" + function upower { case $1 in '-e'|'--enumerate') - echo "/org/freedesktop/UPower/devices/battery_BAT0" + echo "$BAT0" echo "/org/freedesktop/UPower/devices/mouse_hid_${RANDOM}_battery" ;; '-i'|'--show-info') - printf "voltage: 12.191 V\n time to full: 57.3 minutes\n percentage: %s\n capacity: 84.6964" "${percent}" + if [[ $2 == "$BAT0" ]] + then + printf "voltage: 12.191 V\n time to full: 57.3 minutes\n percentage: %s\n capacity: 84.6964" "${percent}" + else + false + fi ;; esac }