From e3d459a148f1d445993e6d9af763b5c100a2f278 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 21 Aug 2014 11:27:52 +0100 Subject: [PATCH] [era_restore] add some cucumber tests --- features/era_restore.feature | 66 ++++++++++++++++++++++++++ features/step_definitions/era_steps.rb | 15 ++++++ 2 files changed, 81 insertions(+) create mode 100644 features/era_restore.feature diff --git a/features/era_restore.feature b/features/era_restore.feature new file mode 100644 index 0000000..b62989c --- /dev/null +++ b/features/era_restore.feature @@ -0,0 +1,66 @@ +Feature: thin_restore + Scenario: print version (-V flag) + When I run era_restore with -V + Then it should pass with version + + Scenario: print version (--version flag) + When I run era_restore with --version + Then it should pass with version + + Scenario: print help (-h) + When I run era_restore with -h + Then it should pass + And the output should contain exactly: + + """ + Usage: era_restore [options] + Options: + {-h|--help} + {-i|--input} + {-o|--output} + {-V|--version} + + """ + + Scenario: print help (--help) + When I run era_restore with -h + Then it should pass + And the output should contain exactly: + + """ + Usage: era_restore [options] + Options: + {-h|--help} + {-i|--input} + {-o|--output} + {-V|--version} + + """ + + Scenario: missing input file + Given the dev file metadata.bin + When I run era_restore with -o metadata.bin + Then it should fail with: + """ + No input file provided. + """ + + Scenario: input file not found + Given the dev file metadata.bin + When I run era_restore with -i foo.xml -o metadata.bin + Then it should fail + + Scenario: missing output file + When I run era_restore with -i metadata.xml + Then it should fail with: + """ + No output file provided. + """ + + Scenario: successfully restores a valid xml file + Given a small era xml file + And an empty dev file + When I run era_restore with -i metadata.xml -o metadata.bin + Then it should pass + And the metadata should be valid + \ No newline at end of file diff --git a/features/step_definitions/era_steps.rb b/features/step_definitions/era_steps.rb index a1e9f29..bbdbb2a 100644 --- a/features/step_definitions/era_steps.rb +++ b/features/step_definitions/era_steps.rb @@ -14,3 +14,18 @@ end Then /^era_usage to stderr$/ do assert_partial_output(ERA_USAGE, all_stderr) end + +When(/^I run era_restore with (.*?)$/) do |opts| + run_simple("era_restore #{opts}", false) +end + +Given(/^a small era xml file$/) do + in_current_dir do + system("era_xml create --nr-blocks 100 --nr-writesets 2 --current-era 1000 > #{xml_file}") + end +end + +Then(/^the metadata should be valid$/) do + run_simple("era_check #{dev_file}", true) +end +