File: kwio_test.sh

package info (click to toggle)
kworkflow 20191112-1.2
  • links: PTS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 2,836 kB
  • sloc: perl: 7,354; sh: 2,397; ansic: 80; python: 44; makefile: 38
file content (108 lines) | stat: -rwxr-xr-x 2,774 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash

. ./tests/utils --source-only
. ./src/kwio.sh --source-only

declare -A configurations
sound_file="$PWD/tests/.kwio_test_aux/sound.file"
visual_file="$PWD/tests/.kwio_test_aux/visual.file"

function suite
{
  suite_addTest "testAlertOptions"
  suite_addTest "testAlertDefaultOptions"
  suite_addTest "testAlertCommandPrinting"
}

function setUp
{
  mkdir -p tests/.kwio_test_aux
  configurations["sound_alert_command"]="touch $sound_file"
  configurations["visual_alert_command"]="touch $visual_file"
}

function tearDown
{
  rm -rf tests/.kwio_test_aux
}


function testAlertOptions
{
  configurations["alert"]="n"

  rm -f "$sound_file" "$visual_file"
  alert_completion "" "--alert=vs"
  [[ -f "$sound_file" && -f "$visual_file" ]]
  assertTrue "Alert's vs option didn't work." $?

  rm -f "$sound_file" "$visual_file"
  alert_completion "" "--alert=sv"
  [[ -f "$sound_file" && -f "$visual_file" ]]
  assertTrue "Alert's sv option didn't work." $?

  rm -f "$sound_file" "$visual_file"
  alert_completion "" "--alert=s"
  [[ -f "$sound_file" && ! -f "$visual_file" ]]
  assertTrue "Alert's s option didn't work." $?

  rm -f "$sound_file" "$visual_file"
  alert_completion "" "--alert=v"
  [[ ! -f "$sound_file" && -f "$visual_file" ]]
  assertTrue "Alert's v option didn't work." $?

  rm -f "$sound_file" "$visual_file"
  alert_completion "" "--alert=n"
  [[ ! -f "$sound_file" && ! -f "$visual_file" ]]
  assertTrue "Alert's n option didn't work." $?

  true
}

function testAlertDefaultOptions
{
  mkdir -p tests/.kwio_test_aux

  rm -f "$sound_file" "$visual_file"
  configurations["alert"]="vs"
  alert_completion "" ""
  [[ -f "$sound_file" && -f "$visual_file" ]]
  assertTrue "Alert's vs option didn't work." $?

  rm -f "$sound_file" "$visual_file"
  configurations["alert"]="sv"
  alert_completion "" ""
  [[ -f "$sound_file" && -f "$visual_file" ]]
  assertTrue "Alert's sv option didn't work." $?

  rm -f "$sound_file" "$visual_file"
  configurations["alert"]="s"
  alert_completion "" ""
  [[ -f "$sound_file" && ! -f "$visual_file" ]]
  assertTrue "Alert's s option didn't work." $?

  rm -f "$sound_file" "$visual_file"
  configurations["alert"]="v"
  alert_completion "" ""
  [[ ! -f "$sound_file" && -f "$visual_file" ]]
  assertTrue "Alert's v option didn't work." $?

  rm -f "$sound_file" "$visual_file"
  configurations["alert"]="n"
  alert_completion "" ""
  [[ ! -f "$sound_file" && ! -f "$visual_file" ]]
  assertTrue "Alert's n option didn't work." $?

  true
}

function testAlertCommandPrinting
{
  local expected="TESTING COMMAND"
  configurations["visual_alert_command"]="echo \$COMMAND"
  ret="$(alert_completion "$expected" "--alert=v")"
  assertEquals "Variable $v should exist." "$ret" "$expected"
  true
}

invoke_shunit