🦊 Change download option to work multiple times (#16)
Changed `-D` option to always download the lists supplied, regardless of the database directory being empty or not. This means you can download additional lists after the first program run, or re-download lists later on. It *will* overwrite your custom changes however if your files are called the same as the default list names. Additionally removed dependency on GNU version of cut and added some simple tests for the download functionality. Fixes #16.
This commit is contained in:
parent
dc68887091
commit
7f5c3772e2
6 changed files with 76 additions and 20 deletions
40
test/bemoji_download.bats
Normal file
40
test/bemoji_download.bats
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
setup_file() {
|
||||
# make bemoji executable from anywhere relative to current testfile
|
||||
TEST_DIR="$( cd "$( dirname "$BATS_TEST_FILENAME" )" >/dev/null 2>&1 && pwd )"
|
||||
PATH="$TEST_DIR/..:$PATH"
|
||||
}
|
||||
|
||||
setup() {
|
||||
load 'test_helper/bats-support/load'
|
||||
load 'test_helper/bats-assert/load'
|
||||
load 'test_helper/mocks/stub'
|
||||
|
||||
# mock out interactive picker for static emoji return
|
||||
export BEMOJI_PICKER_CMD="echo heart"
|
||||
|
||||
# set up small default set of test emoji for each test
|
||||
export BEMOJI_DB_LOCATION="$BATS_TEST_TMPDIR/database"
|
||||
export BEMOJI_HISTORY_LOCATION="$BATS_TEST_TMPDIR/history"
|
||||
mkdir -p "$BEMOJI_DB_LOCATION" "$BEMOJI_HISTORY_LOCATION"
|
||||
}
|
||||
|
||||
@test "Runs emoji download on -D emoji option" {
|
||||
stub curl \
|
||||
"echo -e '1F605 ; fully-qualified # emoji E0.6 grinning face with sweat\nnot picked up\n1F605 ; fully-qualified # emoji2 E0.6 picked up'"
|
||||
run bemoji -D emojis 3>&-
|
||||
outcome=$(cat "$BEMOJI_DB_LOCATION/emojis.txt")
|
||||
assert_equal "$outcome" "emoji grinning face with sweat
|
||||
emoji2 picked up"
|
||||
unstub curl
|
||||
}
|
||||
|
||||
@test "Runs maths download on -D maths option" {
|
||||
stub curl \
|
||||
"echo '03A3;A;Σ;Sigma;ISOGRK3;;GREEK CAPITAL LETTER SIGMA'"
|
||||
run bemoji -D math 3>&-
|
||||
outcome=$(cat "$BEMOJI_DB_LOCATION/math.txt")
|
||||
assert_equal "$outcome" "Σ GREEK CAPITAL LETTER SIGMA"
|
||||
unstub curl
|
||||
}
|
||||
1
test/test_helper/mocks
Submodule
1
test/test_helper/mocks
Submodule
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 7e0fbf6bc705bd1b09daa2d5ff88962ddbe832f6
|
||||
Loading…
Add table
Add a link
Reference in a new issue