From 7490b98db691cccd387291e3f14f9478e6b8ed7e Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 25 Mar 2014 16:56:45 -0400 Subject: [PATCH] Combine database and db_entry tests These tests are designed to verify the database, which should include the DatabaseEntry class. Signed-off-by: Anna Schumaker --- tests/Sconscript | 3 +- tests/database | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ tests/db_entry | 65 ------------------------------------------ 3 files changed, 75 insertions(+), 67 deletions(-) delete mode 100755 tests/db_entry diff --git a/tests/Sconscript b/tests/Sconscript index 887c4420..011f97a5 100644 --- a/tests/Sconscript +++ b/tests/Sconscript @@ -8,8 +8,7 @@ if sys.argv.count("tests") > 0: src = SConscript("src/Sconscript") -tests = [ "version", "file", "db_entry", "database", "index", - "filter", "idle", "tag_db" ] +tests = [ "version", "file", "database", "index", "filter", "idle", "tag_db" ] #scripts = [ "playlist", "library", "playqueue", "deck", "audio", "gui" ] prev = None diff --git a/tests/database b/tests/database index 2dfac707..62614c1a 100755 --- a/tests/database +++ b/tests/database @@ -3,6 +3,80 @@ . $(dirname $0)/_functions + +### +# +# First, verify everything for a DatabaseEntry +# + +function test_entry +{ + test_equal "./src/db_entry.run $1 $2" "$3" +} + +function test_print +{ + test_entry $1 $2 "Value: $1 Key: $2 Id: 0" +} + +function test_primary_key +{ + test_entry "-p $1" $2 "Primary key: $2" +} + +function test_write +{ + rm $DATA_DIR/db_entry.txt 2>/dev/null || true + ./src/db_entry.run -w $1 $2 + test_equal "tail -1 $DATA_DIR/db_entry.txt" "$1 $2" +} + +function test_read +{ + rm $DATA_DIR/db_entry.txt 2>/dev/null || true + echo 0 > $DATA_DIR/db_entry.txt + echo $1 $2 >> $DATA_DIR/db_entry.txt + test_entry "-r $1" $2 "Value: $1 Key: $2 Id: 0" +} + + +new_test "Database Entry Print Test" +test_print 1 1 +test_print 1 2 +test_print 2 1 +test_print 2 2 + + +echo +new_test "Database Entry Primary Key Test" +test_primary_key 1 1 +test_primary_key 1 2 +test_primary_key 2 1 +test_primary_key 2 2 + + +echo +new_test "Database Entry Write Test" +test_write 1 1 +test_write 1 2 +test_write 2 1 +test_write 2 2 + + +echo +new_test "Database Entry Read Test" +test_read 1 1 +test_read 1 2 +test_read 2 1 +test_read 2 2 + + +echo +### +# +# Now, test the actual database +# + function test_autosave { new_test "Database Test (n = $1, autosave = true)" diff --git a/tests/db_entry b/tests/db_entry deleted file mode 100755 index 3517caeb..00000000 --- a/tests/db_entry +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/bash -# Copyright 2014 (c) Anna Schumaker - -. $(dirname $0)/_functions - -function test_entry -{ - test_equal "./src/db_entry.run $1 $2" "$3" -} - -function test_print -{ - test_entry $1 $2 "Value: $1 Key: $2 Id: 0" -} - -function test_primary_key -{ - test_entry "-p $1" $2 "Primary key: $2" -} - -function test_write -{ - rm $DATA_DIR/db_entry.txt 2>/dev/null || true - ./src/db_entry.run -w $1 $2 - test_equal "tail -1 $DATA_DIR/db_entry.txt" "$1 $2" -} - -function test_read -{ - rm $DATA_DIR/db_entry.txt 2>/dev/null || true - echo 0 > $DATA_DIR/db_entry.txt - echo $1 $2 >> $DATA_DIR/db_entry.txt - test_entry "-r $1" $2 "Value: $1 Key: $2 Id: 0" -} - - -new_test "Database Entry Print Test" -test_print 1 1 -test_print 1 2 -test_print 2 1 -test_print 2 2 - - -echo -new_test "Database Entry Primary Key Test" -test_primary_key 1 1 -test_primary_key 1 2 -test_primary_key 2 1 -test_primary_key 2 2 - - -echo -new_test "Database Entry Write Test" -test_write 1 1 -test_write 1 2 -test_write 2 1 -test_write 2 2 - - -echo -new_test "Database Entry Read Test" -test_read 1 1 -test_read 1 2 -test_read 2 1 -test_read 2 2