diff options
author | Alberto <alberto.ruiz@codethink.co.uk> | 2011-10-03 15:57:38 +0100 |
---|---|---|
committer | Alberto <alberto.ruiz@codethink.co.uk> | 2011-10-03 15:57:38 +0100 |
commit | 89fd8c09238b252b7e66c803937ddc9e8b5e2cd2 (patch) | |
tree | 3c44b9246ebfbe70d4e8fae99e836fe7e77ca613 | |
parent | 7000a3a6909294aed8c3ad794edbdddc3261c45c (diff) | |
download | tbdiff-89fd8c09238b252b7e66c803937ddc9e8b5e2cd2.tar.gz |
Additions to the testing README
-rw-r--r-- | README.testing | 49 | ||||
-rwxr-xr-x | tests/02_symlink_add_remove.sh | 4 | ||||
-rwxr-xr-x | tests/03_regular_file_add_remove.sh | 4 |
3 files changed, 48 insertions, 9 deletions
diff --git a/README.testing b/README.testing index 36f2453..ce67880 100644 --- a/README.testing +++ b/README.testing @@ -13,8 +13,55 @@ You need to change to the tests directory and execute run_tests.sh: $ ./run_tests.sh +To run each test individually: + +$ ./00_my_individual_test.sh ../path/to/test-create ../path/to/test-deploy Anatomy of a unit test ---------------------- -Each test +Each test needs to copy the following boilerplate: + + #!/bin/bash + + TEST_ID="01" + TEST_NAME="My unit test" + + CREATE=`pwd`/$1 + DEPLOY=`pwd`/$2 + TEST_TOOLS=$3 + . ./test_lib.sh + + ############# Test specific code ############ + function setup { + } + + function check_results { + } + ############################################# + main $@ + +Test lib is a bash function library that sets up the environment for the test. +To create a test, we have two main variables $ORIGIN and $TARGET which are the +origin and target directories of the diff respectively. The setup function +should populate the origin and the target directories for the diff test. + +This is an example of a simple file difference test. It takes into account both +contents and metadata (mtime, ownership and permissions): + + ORG_FILE=$ORIGIN/b.txt + TGT_FILE=$TARGET/b.txt + + function setup { + echo 1 > $ORG_FILE && \ + echo 2 > $TGT_FILE && \ + chown :cdrom $TGT_FILE && \ + chmod 707 $TGT_FILE + } + + function check_results { + check_content $ORG_FILE "2" && \ + check_perm $ORG_FILE 707 && \ + check_group $ORG_FILE cdrom && \ + check_same_mtime $ORG_FILE $TGT_FILE + } diff --git a/tests/02_symlink_add_remove.sh b/tests/02_symlink_add_remove.sh index e4b81a9..6fe54d8 100755 --- a/tests/02_symlink_add_remove.sh +++ b/tests/02_symlink_add_remove.sh @@ -11,16 +11,12 @@ TEST_TOOLS=$3 ############# Test specific code ############ -# This test checks that normal files content and metadata are - function setup { ln -s /foo $ORIGIN/remove && \ ln -s /bar $TARGET/add && \ chown -h :cdrom $TARGET/add } -# check_same_mtime FILE_A FILE_B - function check_results { test -L $ORIGIN/add && \ test ! -L $ORIGIN/remove && \ diff --git a/tests/03_regular_file_add_remove.sh b/tests/03_regular_file_add_remove.sh index f8b5652..cdf3eab 100755 --- a/tests/03_regular_file_add_remove.sh +++ b/tests/03_regular_file_add_remove.sh @@ -11,16 +11,12 @@ TEST_TOOLS=$3 ############# Test specific code ############ -# This test checks that normal files content and metadata are - function setup { touch $ORIGIN/remove && \ echo 1 > $TARGET/add && \ chown -h :cdrom $TARGET/add } -# check_same_mtime FILE_A FILE_B - function check_results { test -f $ORIGIN/add && \ test ! -f $ORIGIN/remove && \ |