From 8c251018c6fabf1fd209d80f04a7bb509becce23 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 30 Aug 2017 10:39:58 +0100 Subject: [PATCH] [functional-tests] thin_delta tests --- features/thin_delta.feature | 62 ------------------- .../scenario-string-constants.scm | 12 ++++ functional-tests/thin-functional-tests.scm | 45 +++++++++++++- 3 files changed, 56 insertions(+), 63 deletions(-) delete mode 100644 features/thin_delta.feature diff --git a/features/thin_delta.feature b/features/thin_delta.feature deleted file mode 100644 index 4363a9e..0000000 --- a/features/thin_delta.feature +++ /dev/null @@ -1,62 +0,0 @@ -Feature: thin_delta - Scenario: print version (-V flag) - When I run `thin_delta -V` - Then it should pass with version - - Scenario: print version (--version flag) - When I run `thin_delta --version` - Then it should pass with version - - Scenario: print help - When I run `thin_delta --help` - Then it should pass with: - - """ - Usage: thin_delta [options] - Options: - {--thin1, --snap1} - {--thin2, --snap2} - {-m, --metadata-snap} [block#] - {--verbose} - {-h|--help} - {-V|--version} - """ - - Scenario: print help - When I run `thin_delta -h` - Then it should pass with: - """ - Usage: thin_delta [options] - Options: - {--thin1, --snap1} - {--thin2, --snap2} - {-m, --metadata-snap} [block#] - {--verbose} - {-h|--help} - {-V|--version} - """ - - Scenario: Unrecognised option should cause failure - When I run `thin_delta --unleash-the-hedeghogs` - Then it should fail - - Scenario: --snap1 must be specified - When I run `thin_delta --snap2 45 foo` - Then it should fail with: - """ - --snap1 not specified. - """ - - Scenario: --snap2 must be specified - When I run `thin_delta --snap1 45 foo` - Then it should fail with: - """ - --snap2 not specified. - """ - - Scenario: device must be specified - When I run `thin_delta --snap1 45 --snap2 50` - Then it should fail with: - """ - No input device provided. - """ diff --git a/functional-tests/scenario-string-constants.scm b/functional-tests/scenario-string-constants.scm index f605e44..8c870d4 100644 --- a/functional-tests/scenario-string-constants.scm +++ b/functional-tests/scenario-string-constants.scm @@ -5,6 +5,7 @@ thin-restore-outfile-too-small-text thin-restore-help thin-rmap-help + thin-delta-help cache-check-help cache-restore-help @@ -54,6 +55,16 @@ Where: is of the form .. for example 5..45 denotes blocks 5 to 44 inclusive, but not block 45") + (define thin-delta-help + "Usage: thin_delta [options] +Options: + {--thin1, --snap1} + {--thin2, --snap2} + {-m, --metadata-snap} [block#] + {--verbose} + {-h|--help} + {-V|--version}") + (define cache-check-help "Usage: cache_check [options] {device|file} Options: @@ -105,4 +116,5 @@ Options: These all relate to the size of the fast device (eg, SSD), rather than the whole cached device.") + ) diff --git a/functional-tests/thin-functional-tests.scm b/functional-tests/thin-functional-tests.scm index 8767391..46e43ff 100644 --- a/functional-tests/thin-functional-tests.scm +++ b/functional-tests/thin-functional-tests.scm @@ -227,5 +227,48 @@ (define-scenario (thin-rmap multiple-regions-should-pass) "thin_rmap should handle multiple regions." (with-valid-metadata (md) - (thin-rmap "--region 1..23 --region 45..78" md)))) + (thin-rmap "--region 1..23 --region 45..78" md))) + ;;;----------------------------------------------------------- + ;;; thin_delta scenarios + ;;;----------------------------------------------------------- + (define-scenario (thin-delta v) + "thin_delta accepts -V" + (receive (stdout _) (thin-delta "-V") + (assert-equal tools-version stdout))) + + (define-scenario (thin-delta version) + "thin_delta accepts --version" + (receive (stdout _) (thin-delta "--version") + (assert-equal tools-version stdout))) + + (define-scenario (thin-delta h) + "thin_delta accepts -h" + (receive (stdout _) (thin-delta "-h") + (assert-equal thin-delta-help stdout))) + + (define-scenario (thin-delta help) + "thin_delta accepts --help" + (receive (stdout _) (thin-delta "--help") + (assert-equal thin-delta-help stdout))) + + (define-scenario (thin-delta unrecognised-option) + "Unrecognised option should cause failure" + (run-fail "thin_delta --unleash-the-hedgehogs")) + + (define-scenario (thin-delta snap1-unspecified) + "Fails without --snap1 fails" + (receive (_ stderr) (run-fail "thin_delta --snap2 45 foo") + (assert-starts-with "--snap1 not specified." stderr))) + + (define-scenario (thin-delta snap2-unspecified) + "Fails without --snap2 fails" + (receive (_ stderr) (run-fail "thin_delta --snap1 45 foo") + (assert-starts-with "--snap2 not specified." stderr))) + + (define-scenario (thin-delta device-unspecified) + "Fails if no device given" + (receive (_ stderr) (run-fail "thin_delta --snap1 45 --snap2 46") + (assert-starts-with "No input device provided." stderr))) + +)