summaryrefslogtreecommitdiff
path: root/spec/integration
diff options
context:
space:
mode:
authorjkeiser <jkeiser@opscode.com>2013-01-20 14:33:14 -0800
committerJohn Keiser <jkeiser@opscode.com>2013-06-07 13:12:25 -0700
commit60cdaa1ec495f156b8424e094cc28bbc73c5768a (patch)
treeea2598e1f871424ad15d05032acad8b67f7e5812 /spec/integration
parent79557d0b72fd0cc91015de2a0ad016c09759084b (diff)
downloadchef-60cdaa1ec495f156b8424e094cc28bbc73c5768a.tar.gz
Print error for bad json in knife upload
Diffstat (limited to 'spec/integration')
-rw-r--r--spec/integration/knife/diff_spec.rb4
-rw-r--r--spec/integration/knife/download_spec.rb11
-rw-r--r--spec/integration/knife/show_spec.rb10
-rw-r--r--spec/integration/knife/upload_spec.rb11
4 files changed, 34 insertions, 2 deletions
diff --git a/spec/integration/knife/diff_spec.rb b/spec/integration/knife/diff_spec.rb
index 9a4cc73db1..cf49dbef74 100644
--- a/spec/integration/knife/diff_spec.rb
+++ b/spec/integration/knife/diff_spec.rb
@@ -292,8 +292,8 @@ EOM
environment 'x', {}
when_the_repository 'has an environment with bad JSON' do
file 'environments/x.json', '{'
- it 'knife diff reports a warning and does a textual diff' do
- knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => "ERROR: Parse error reading #{path_to('environments/x.json')} as JSON: A JSON text must at least contain two octets!\n")
+ 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")
end
end
end
diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb
index 8baee8803b..a8f8215389 100644
--- a/spec/integration/knife/download_spec.rb
+++ b/spec/integration/knife/download_spec.rb
@@ -497,4 +497,15 @@ EOM
end
end
end
+
+ when_the_chef_server 'has an environment' do
+ environment 'x', {}
+ when_the_repository 'has an environment with bad JSON' do
+ file 'environments/x.json', '{'
+ 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
+ end
end
diff --git a/spec/integration/knife/show_spec.rb b/spec/integration/knife/show_spec.rb
index 0a1d89caac..51aa38960e 100644
--- a/spec/integration/knife/show_spec.rb
+++ b/spec/integration/knife/show_spec.rb
@@ -128,4 +128,14 @@ EOM
EOM
end
end
+
+ when_the_repository 'has an environment with bad JSON' do
+ file 'environments/x.json', '{'
+ it 'knife show succeeds' do
+ knife('show --local /environments/x.json').should_succeed <<EOM
+/environments/x.json:
+{
+EOM
+ end
+ end
end
diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb
index 62f4c0ce16..21b0bd41d5 100644
--- a/spec/integration/knife/upload_spec.rb
+++ b/spec/integration/knife/upload_spec.rb
@@ -513,4 +513,15 @@ EOM
end
end
end
+
+ when_the_chef_server 'has an environment' do
+ environment 'x', {}
+ when_the_repository 'has an environment with bad JSON' do
+ file 'environments/x.json', '{'
+ 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
+ end
end