Create file named after isosec
This commit is contained in:
parent
eeb7f983ae
commit
621340140e
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
TMP_ZETTELKASTEN=""
|
||||
|
||||
setup() {
|
||||
source ../zk
|
||||
|
||||
TMP_ZETTELKASTEN="$(mktemp -d)"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
rm -rf "$TMP_ZETTELKASTEN"
|
||||
}
|
||||
|
||||
test__zk_new_creates_file_in_correct_directory() {
|
||||
export ZKDIR="$TMP_ZETTELKASTEN"
|
||||
filename="aaaaaaaaaaaaaa"
|
||||
fake date "echo $filename"
|
||||
|
||||
_zk_new
|
||||
|
||||
assert "test -e $TMP_ZETTELKASTEN/$filename"
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
setup() {
|
||||
source ../zk
|
||||
}
|
||||
|
||||
test_isosec_calls_date_with_correct_parameters() {
|
||||
expected="date -u +%Y%m%d%H%M%S"
|
||||
# shellcheck disable=SC2016
|
||||
fake date echo 'date ${FAKE_PARAMS[@]}'
|
||||
|
||||
result="$(_zk_isosec)"
|
||||
|
||||
assert_equals "$expected" "$result"
|
||||
}
|
9
zk
9
zk
|
@ -14,12 +14,21 @@ get_command() {
|
|||
done
|
||||
}
|
||||
|
||||
_zk_isosec() {
|
||||
date -u +%Y%m%d%H%M%S
|
||||
}
|
||||
|
||||
_zk_list() {
|
||||
for zettel in "$ZKDIR"/*; do
|
||||
echo "$(basename "$zettel") | $(head -1 "$zettel")"
|
||||
done
|
||||
}
|
||||
|
||||
_zk_new() {
|
||||
filename="$(_zk_isosec)"
|
||||
touch "$ZKDIR/$filename"
|
||||
}
|
||||
|
||||
main() {
|
||||
subcommand="$(get_commands "$COMMANDS" "$1")"
|
||||
_zk_"$subcommand"
|
||||
|
|
Loading…
Reference in New Issue