zk/tests/test_main.sh

57 lines
1.0 KiB
Bash
Raw Normal View History

2023-12-08 16:08:34 +00:00
#!/bin/bash
setup() {
source ../zk
}
2023-12-08 17:29:26 +00:00
test_main_calls_list_when_list_command_passed() {
2023-12-08 19:37:42 +00:00
fake check_zkdir test
2023-12-08 17:29:26 +00:00
expected="_zk_list"
fake get_command 'echo list'
fake _zk_list "echo $expected"
2023-12-08 16:08:34 +00:00
result="$(main)"
assert_equals "$expected" "$result"
}
2023-12-08 17:29:26 +00:00
test_main_calls_search_when_search_command_passed() {
2023-12-08 19:37:42 +00:00
fake check_zkdir test
2023-12-08 17:29:26 +00:00
expected="_zk_search"
fake get_command 'echo search'
fake _zk_search "echo $expected"
2023-12-08 16:08:34 +00:00
result="$(main)"
assert_equals "$expected" "$result"
}
2023-12-08 17:29:26 +00:00
test_main_calls_new_when_new_command_passed() {
2023-12-08 19:37:42 +00:00
fake check_zkdir test
2023-12-08 17:29:26 +00:00
expected="_zk_new"
fake get_command 'echo new'
fake _zk_new "echo $expected"
result="$(main)"
assert_equals "$expected" "$result"
}
2023-12-08 17:57:00 +00:00
test_main_calls_edit_when_edit_command_passed() {
2023-12-08 19:37:42 +00:00
fake check_zkdir test
2023-12-08 17:57:00 +00:00
expected="_zk_edit"
fake get_command 'echo edit'
fake _zk_edit "echo $expected"
result="$(main)"
assert_equals "$expected" "$result"
}
2023-12-08 19:37:42 +00:00
test_main_errors_if_unrecognized_command_given() {
fake check_zkdir test
fake get_command echo ""
assert_status_code 2 main
}