File: t6090-completion-aliases.sh

package info (click to toggle)
todotxt-cli 2.11.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,312 kB
  • sloc: sh: 5,393; makefile: 67
file content (62 lines) | stat: -rwxr-xr-x 1,365 bytes parent folder | download | duplicates (3)
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
#!/bin/bash
#

test_description='Bash completion with different aliases functionality

This test checks that todo_completion can use a different configuration
when another todo-txt alias is defined that uses that configuration.
'
. ./test-lib.sh

cat > todo.txt <<EOF
(B) smell the +roses @outside @outdoor +shared
notice the sunflowers +sunflowers @outside @garden +shared +landscape
stop
EOF
cat > todo2.txt <<EOF
+herbs @oriental buy spices
+slack @home watch tv
EOF

cp todo.cfg todo2.cfg
cat >> todo2.cfg <<'EOF'
export TODO_FILE="$TODO_DIR/todo2.txt"
EOF

# Note: We cannot use aliases within the test framework, but functions are
# equivalent and work fine.
todo1()
{
    todo-txt "$@"
}
todo2()
{
    todo-txt -d "$HOME/todo2.cfg" "$@"
}

# Ensure that the test fixture works as planned.
test_todo_session 'todo 1 and 2 contexts' <<EOF
>>> todo1 listcon
@garden
@outdoor
@outside

>>> todo2 listcon
@home
@oriental
EOF


# Define a second completion function that injects the different configuration
# file. In real use, this would be installed via
#   complete -F _todo2 todo2
_todo2()
{
    local _todo_sh='todo-txt -d "$HOME/todo2.cfg"'
    _todo "$@"
}

test_todo_completion               'all todo1 contexts' 'todo1 list @' '@garden @outdoor @outside'
test_todo_custom_completion _todo2 'all todo2 contexts' 'todo2 list @' '@home @oriental'

test_done