Add hash test

This commit is contained in:
Lukáš Kucharczyk 2022-11-16 08:56:15 +01:00
parent 907f9b742d
commit ec5cb5bb17
Signed by: lukas
SSH Key Fingerprint: SHA256:vMuSwvwAvcT6htVAioMP7rzzwMQNi3roESyhv+nAxeg
1 changed files with 9 additions and 3 deletions

View File

@ -3,6 +3,7 @@ set -ueo pipefail
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
DB_FILE="test.db"
FILENAME="test.mp4"
oneTimeSetUp() {
tag --db "$DB_FILE" init >/dev/null
@ -27,7 +28,6 @@ testTagAdded() {
}
testFilenameAdded() {
local FILENAME="test.mp4"
tag --db "$DB_FILE" add path "$FILENAME" >/dev/null
RESULT=$(sqlite3 "$DB_FILE" "SELECT filename from files WHERE filename = '$FILENAME'")
assertEquals "$RESULT" "$FILENAME"
@ -35,9 +35,15 @@ testFilenameAdded() {
testHashAdded() {
local HASH="fbe2153ce0614d76a378b2e6fe07cc9e"
tag --db "$DB_FILE" add hash "$HASH" >/dev/null
RESULT=$(sqlite3 "$DB_FILE" "SELECT md5 from hashes WHERE hash = '$HASH'")
tag --db "$DB_FILE" add hash "$FILENAME" "$HASH" >/dev/null
RESULT=$(sqlite3 "$DB_FILE" "SELECT md5 from hashes WHERE md5 = '$HASH'")
assertEquals "$RESULT" "$HASH"
}
testFailAddingHashOnNonexistentFile() {
local HASH="fbe2153ce0614d76a378b2e6fe07cc9e"
tag --db "$DB_FILE" add hash "nonexistentfile" "$HASH" 2>/dev/null
assertEquals "$?" 1
}
. ../shunit2/shunit2