Browse Source

Add test for sending folder to chest and remove test files

pull/1/head
Luke Childs 9 years ago
parent
commit
8f2d64d754
  1. 1
      .gitignore
  2. 0
      folder/bar
  3. 0
      folder/foo
  4. 16
      tests/helper_functions.bash
  5. 20
      tests/tests.bats
  6. 1
      tests/variables.bash

1
.gitignore

@ -0,0 +1 @@
test-folder-*

0
folder/bar

0
folder/foo

16
tests/helper_functions.bash

@ -0,0 +1,16 @@
random_string() {
local length="$1";
env LC_CTYPE=C tr -dc "a-zA-Z0-9" < /dev/urandom | head -c "$length"
}
create_dummy_folders() {
local folder="$1";
mkdir -p "$folder"
touch "$folder/foo"
touch "$folder/bar"
}
teardown() {
# Remove any leftover temp folders
rm -rf test-folder-*
}

20
tests/tests.bats

@ -1,12 +1,14 @@
#!/usr/bin/env bats
load variables
load helper_functions
@test "Check gpg is in PATH" {
command -v gpg
}
@test "Check chest dir gets created" {
run ./chest
chest_dir="${HOME}/.chest"
[[ -d "$chest_dir" ]]
}
@ -16,3 +18,19 @@
echo "${lines[0]}"
[[ "${lines[0]}" = "Usage"* ]]
}
@test "Send a folder to the chest" {
# Generate random folder name
folder="test-folder-$(random_string 8)"
# Create dummy folder and files
create_dummy_folders "$folder"
# Send to chest
./chest -ep "password" "$folder"
# Check it's there
./chest -l | grep "$folder"
}

1
tests/variables.bash

@ -0,0 +1 @@
chest_dir="${HOME}/.chest"
Loading…
Cancel
Save