summaryrefslogtreecommitdiff
path: root/README.testing
diff options
context:
space:
mode:
authorAlberto <alberto.ruiz@codethink.co.uk>2011-10-03 15:57:38 +0100
committerAlberto <alberto.ruiz@codethink.co.uk>2011-10-03 15:57:38 +0100
commit89fd8c09238b252b7e66c803937ddc9e8b5e2cd2 (patch)
tree3c44b9246ebfbe70d4e8fae99e836fe7e77ca613 /README.testing
parent7000a3a6909294aed8c3ad794edbdddc3261c45c (diff)
downloadtbdiff-89fd8c09238b252b7e66c803937ddc9e8b5e2cd2.tar.gz
Additions to the testing README
Diffstat (limited to 'README.testing')
-rw-r--r--README.testing49
1 files changed, 48 insertions, 1 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
+ }