2017-07-16 03:07:53 +02:00
|
|
|
#!/bin/env bats
|
|
|
|
|
|
|
|
@test "Testing todo tool" {
|
|
|
|
echo todo
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Check for latest version of bash-snippets on update" {
|
2017-08-02 08:05:17 +02:00
|
|
|
if [[ "$(uname)" == "Linux" ]];then
|
2017-07-16 03:07:53 +02:00
|
|
|
run todo update
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "Bash-Snippets is already the latest version" ]
|
2017-08-02 08:05:17 +02:00
|
|
|
fi
|
2017-07-16 03:07:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "No arguments prints usage instructions" {
|
|
|
|
run todo
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "${lines[0]}" = "Todo" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "The -h option should print usage" {
|
|
|
|
run todo -h
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "${lines[0]}" = "Todo" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Adding task" {
|
|
|
|
run todo -a First task ever
|
|
|
|
[ "$status" -eq 0 ]
|
2017-07-16 03:14:44 +02:00
|
|
|
result=$( echo $(todo -g) | grep -Eo "01\). First task ever" )
|
2017-07-16 03:07:53 +02:00
|
|
|
[ "$result" = "01). First task ever" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Getting task" {
|
|
|
|
run todo -g
|
|
|
|
[ "$status" -eq 0 ]
|
2017-07-16 03:14:44 +02:00
|
|
|
result=$( echo $(todo -g) | grep -Eo "01\). First task ever" )
|
2017-07-16 03:07:53 +02:00
|
|
|
[ "$result" = "01). First task ever" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Removing task" {
|
|
|
|
run todo -r "1"
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
result=$( cat ~/.todo/list.txt )
|
|
|
|
echo $result
|
|
|
|
[ "$result" = "" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Getting from empty task list" {
|
|
|
|
run todo -g
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "No tasks found" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "Get the tools version with -v" {
|
|
|
|
run todo -v
|
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
result=$( echo $(todo -v) | grep -Eo "Version")
|
|
|
|
[ "$result" = "Version" ]
|
|
|
|
}
|