diff options
Diffstat (limited to 'spec/integration/knife')
-rw-r--r-- | spec/integration/knife/diff_spec.rb | 8 | ||||
-rw-r--r-- | spec/integration/knife/download_spec.rb | 19 | ||||
-rw-r--r-- | spec/integration/knife/upload_spec.rb | 48 |
3 files changed, 31 insertions, 44 deletions
diff --git a/spec/integration/knife/diff_spec.rb b/spec/integration/knife/diff_spec.rb index 8d13d86a99..62b491d6ef 100644 --- a/spec/integration/knife/diff_spec.rb +++ b/spec/integration/knife/diff_spec.rb @@ -309,7 +309,9 @@ EOM when_the_repository 'has an environment with bad JSON' do before { file 'environments/x.json', '{' } it 'knife diff reports an error and does a textual diff' do - knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n") + error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF" + error_match = Regexp.new(Regexp.escape(error_text)) + knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => error_match) end end end @@ -590,7 +592,9 @@ EOM when_the_repository 'has an environment with bad JSON' do before { file 'environments/x.json', '{' } it 'knife diff reports an error and does a textual diff' do - knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n") + error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF" + error_match = Regexp.new(Regexp.escape(error_text)) + knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => error_match) end end end diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb index 4788a564b7..2ef5dc03c1 100644 --- a/spec/integration/knife/download_spec.rb +++ b/spec/integration/knife/download_spec.rb @@ -541,7 +541,13 @@ EOM file 'environments/x.json', '{' end it 'knife download succeeds' do - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n" + warning = <<-EOH +WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF + { + (right here) ------^ + +EOH + knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => warning knife('diff --name-status /environments/x.json').should_succeed '' end end @@ -1033,17 +1039,6 @@ EOM environment 'x', {} end - when_the_repository 'has an environment with bad JSON' do - before do - file 'environments/x.json', '{' - end - - it 'knife download succeeds' do - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n" - knife('diff --name-status /environments/x.json').should_succeed '' - end - end - when_the_repository 'has the same environment with the wrong name in the file' do before do file 'environments/x.json', { 'name' => 'y' } diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb index 90666f4fc9..d8db27f73b 100644 --- a/spec/integration/knife/upload_spec.rb +++ b/spec/integration/knife/upload_spec.rb @@ -605,8 +605,24 @@ EOM end it 'knife upload tries and fails' do - knife('upload /environments/x.json').should_fail "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\nERROR: /environments/x.json failed to write: Parse error reading JSON: A JSON text must at least contain two octets!\n" - knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n" + error1 = <<-EOH +WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF + { + (right here) ------^ + +ERROR: /environments/x.json failed to write: Parse error reading JSON: parse error: premature EOF + { + (right here) ------^ +EOH + + warn = <<-EOH +WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF + { + (right here) ------^ + +EOH + knife('upload /environments/x.json').should_fail(error1) + knife('diff --name-status /environments/x.json').should_succeed("M\t/environments/x.json\n", :stderr => warn) end end @@ -632,15 +648,6 @@ EOM end when_the_chef_server 'is empty' do - when_the_repository 'has an environment with bad JSON' do - before do - file 'environments/x.json', '{' - end - it 'knife upload tries and fails' do - knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Parse error reading JSON creating child 'x.json': A JSON text must at least contain two octets!\n" - knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n" - end - end when_the_repository 'has an environment with the wrong name in the file' do before do @@ -1140,16 +1147,6 @@ EOM environment 'x', {} end - when_the_repository 'has an environment with bad JSON' do - before do - file 'environments/x.json', '{' - end - it 'knife upload tries and fails' do - knife('upload /environments/x.json').should_fail "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\nERROR: /environments/x.json failed to write: Parse error reading JSON: A JSON text must at least contain two octets!\n" - knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n", :stderr => "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n" - end - end - when_the_repository 'has the same environment with the wrong name in the file' do before do file 'environments/x.json', { 'name' => 'y' } @@ -1172,15 +1169,6 @@ EOM end when_the_chef_server 'is empty' do - when_the_repository 'has an environment with bad JSON' do - before do - file 'environments/x.json', '{' - end - it 'knife upload tries and fails' do - knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Parse error reading JSON creating child 'x.json': A JSON text must at least contain two octets!\n" - knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n" - end - end when_the_repository 'has an environment with the wrong name in the file' do before do |