knife-essentials 0.8.4 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/chef/knife/delete_essentials.rb +37 -8
- data/lib/chef/knife/deps_essentials.rb +5 -5
- data/lib/chef/knife/diff_essentials.rb +9 -1
- data/lib/chef/knife/download_essentials.rb +1 -1
- data/lib/chef/knife/list_essentials.rb +5 -5
- data/lib/chef/knife/raw_essentials.rb +7 -2
- data/lib/chef/knife/show_essentials.rb +14 -4
- data/lib/chef/knife/upload_essentials.rb +1 -1
- data/lib/chef_fs/command_line.rb +18 -10
- data/lib/chef_fs/file_system.rb +4 -4
- data/lib/chef_fs/file_system/base_fs_object.rb +10 -10
- data/lib/chef_fs/file_system/chef_repository_file_system_root_dir.rb +1 -1
- data/lib/chef_fs/file_system/chef_server_root_dir.rb +0 -2
- data/lib/chef_fs/file_system/cookbook_dir.rb +17 -12
- data/lib/chef_fs/file_system/cookbooks_dir.rb +1 -1
- data/lib/chef_fs/file_system/data_bag_dir.rb +4 -3
- data/lib/chef_fs/file_system/data_bag_item.rb +1 -1
- data/lib/chef_fs/file_system/data_bags_dir.rb +2 -2
- data/lib/chef_fs/file_system/{operation_skipped_error.rb → default_environment_cannot_be_modified_error.rb} +8 -3
- data/lib/chef_fs/file_system/environments_dir.rb +5 -7
- data/lib/chef_fs/file_system/file_system_entry.rb +6 -6
- data/lib/chef_fs/file_system/must_delete_recursively_error.rb +4 -1
- data/lib/chef_fs/file_system/nodes_dir.rb +2 -2
- data/lib/chef_fs/file_system/nonexistent_fs_object.rb +0 -12
- data/lib/chef_fs/file_system/not_found_error.rb +4 -1
- data/lib/chef_fs/file_system/operation_not_allowed_error.rb +19 -1
- data/lib/chef_fs/file_system/rest_list_dir.rb +2 -2
- data/lib/chef_fs/file_system/rest_list_entry.rb +3 -3
- data/lib/chef_fs/knife.rb +5 -4
- data/lib/chef_fs/path_utils.rb +6 -4
- data/lib/chef_fs/version.rb +1 -1
- data/spec/integration/delete_spec.rb +684 -0
- data/spec/integration/diff_spec.rb +75 -1
- data/spec/integration/download_spec.rb +101 -4
- data/spec/integration/raw_spec.rb +171 -0
- data/spec/integration/show_spec.rb +124 -0
- data/spec/integration/upload_spec.rb +122 -13
- metadata +6 -3
@@ -97,7 +97,15 @@ EOM
|
|
97
97
|
EOM
|
98
98
|
|
99
99
|
it 'knife diff reports no differences' do
|
100
|
-
knife('diff /').should_succeed
|
100
|
+
knife('diff /').should_succeed ''
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'knife diff /environments/nonexistent.json reports an error' do
|
104
|
+
knife('diff /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory on remote or local\n"
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'knife diff /environments/*.txt reports an error' do
|
108
|
+
knife('diff /environments/*.txt').should_fail "ERROR: /environments/*.txt: No such file or directory on remote or local\n"
|
101
109
|
end
|
102
110
|
|
103
111
|
context 'except the role file' do
|
@@ -134,6 +142,22 @@ A\t/environments/y.json
|
|
134
142
|
A\t/roles/y.json
|
135
143
|
EOM
|
136
144
|
end
|
145
|
+
|
146
|
+
context 'when cwd is the data_bags directory' do
|
147
|
+
cwd 'data_bags'
|
148
|
+
it 'knife diff reports different data bags' do
|
149
|
+
knife('diff --name-status').should_succeed <<EOM
|
150
|
+
A\tx/z.json
|
151
|
+
A\ty
|
152
|
+
EOM
|
153
|
+
end
|
154
|
+
it 'knife diff * reports different data bags' do
|
155
|
+
knife('diff --name-status *').should_succeed <<EOM
|
156
|
+
A\tx/z.json
|
157
|
+
A\ty
|
158
|
+
EOM
|
159
|
+
end
|
160
|
+
end
|
137
161
|
end
|
138
162
|
end
|
139
163
|
|
@@ -144,6 +168,56 @@ D\t/cookbooks
|
|
144
168
|
D\t/data_bags
|
145
169
|
D\t/environments
|
146
170
|
D\t/roles
|
171
|
+
EOM
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
when_the_repository 'has a cookbook' do
|
177
|
+
file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
|
178
|
+
file 'cookbooks/x/onlyin1.0.0.rb', ''
|
179
|
+
|
180
|
+
when_the_chef_server 'has a later version for the cookbook' do
|
181
|
+
cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"', 'onlyin1.0.0.rb' => ''}
|
182
|
+
cookbook 'x', '1.0.1', { 'metadata.rb' => 'version "1.0.1"', 'onlyin1.0.1.rb' => '' }
|
183
|
+
|
184
|
+
it 'knife diff /cookbooks/x shows differences' do
|
185
|
+
knife('diff --name-status /cookbooks/x').should_succeed <<EOM
|
186
|
+
M\t/cookbooks/x/metadata.rb
|
187
|
+
D\t/cookbooks/x/onlyin1.0.1.rb
|
188
|
+
A\t/cookbooks/x/onlyin1.0.0.rb
|
189
|
+
EOM
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
when_the_chef_server 'has an earlier version for the cookbook' do
|
194
|
+
cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"', 'onlyin1.0.0.rb' => '' }
|
195
|
+
cookbook 'x', '0.9.9', { 'metadata.rb' => 'version "0.9.9"', 'onlyin0.9.9.rb' => '' }
|
196
|
+
it 'knife diff /cookbooks/x shows no differences' do
|
197
|
+
knife('diff --name-status /cookbooks/x').should_succeed ''
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
when_the_chef_server 'has a later version for the cookbook, and no current version' do
|
202
|
+
cookbook 'x', '1.0.1', { 'metadata.rb' => 'version "1.0.1"', 'onlyin1.0.1.rb' => '' }
|
203
|
+
|
204
|
+
it 'knife diff /cookbooks/x shows the differences' do
|
205
|
+
knife('diff --name-status /cookbooks/x').should_succeed <<EOM
|
206
|
+
M\t/cookbooks/x/metadata.rb
|
207
|
+
D\t/cookbooks/x/onlyin1.0.1.rb
|
208
|
+
A\t/cookbooks/x/onlyin1.0.0.rb
|
209
|
+
EOM
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
when_the_chef_server 'has an earlier version for the cookbook, and no current version' do
|
214
|
+
cookbook 'x', '0.9.9', { 'metadata.rb' => 'version "0.9.9"', 'onlyin0.9.9.rb' => '' }
|
215
|
+
|
216
|
+
it 'knife diff /cookbooks/x shows the differences' do
|
217
|
+
knife('diff --name-status /cookbooks/x').should_succeed <<EOM
|
218
|
+
M\t/cookbooks/x/metadata.rb
|
219
|
+
D\t/cookbooks/x/onlyin0.9.9.rb
|
220
|
+
A\t/cookbooks/x/onlyin1.0.0.rb
|
147
221
|
EOM
|
148
222
|
end
|
149
223
|
end
|
@@ -134,6 +134,30 @@ EOM
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
+
context 'except the role file is textually different, but not ACTUALLY different' do
|
138
|
+
file 'roles/x.json', <<EOM
|
139
|
+
{
|
140
|
+
"chef_type": "role",
|
141
|
+
"default_attributes": {
|
142
|
+
},
|
143
|
+
"env_run_lists": {
|
144
|
+
},
|
145
|
+
"json_class": "Chef::Role",
|
146
|
+
"name": "x",
|
147
|
+
"description": "",
|
148
|
+
"override_attributes": {
|
149
|
+
},
|
150
|
+
"run_list": [
|
151
|
+
|
152
|
+
]
|
153
|
+
}
|
154
|
+
EOM
|
155
|
+
it 'knife download / does not change anything' do
|
156
|
+
knife('download /').should_succeed ''
|
157
|
+
knife('diff --name-status /').should_succeed ''
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
137
161
|
context 'as well as one extra copy of each thing' do
|
138
162
|
file 'clients/y.json', { 'name' => 'y' }
|
139
163
|
file 'cookbooks/x/blah.rb', ''
|
@@ -337,6 +361,28 @@ Deleted extra entry /data_bags/x/deleted.json (purge is on)
|
|
337
361
|
EOM
|
338
362
|
knife('diff --name-status /data_bags').should_succeed ''
|
339
363
|
end
|
364
|
+
context 'when cwd is the /data_bags directory' do
|
365
|
+
cwd 'data_bags'
|
366
|
+
it 'knife download fails' do
|
367
|
+
knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/
|
368
|
+
end
|
369
|
+
it 'knife download --purge . downloads everything' do
|
370
|
+
knife('download --purge .').should_succeed <<EOM
|
371
|
+
Created x/added.json
|
372
|
+
Updated x/modified.json
|
373
|
+
Deleted extra entry x/deleted.json (purge is on)
|
374
|
+
EOM
|
375
|
+
knife('diff --name-status /data_bags').should_succeed ''
|
376
|
+
end
|
377
|
+
it 'knife download --purge * downloads everything' do
|
378
|
+
knife('download --purge *').should_succeed <<EOM
|
379
|
+
Created x/added.json
|
380
|
+
Updated x/modified.json
|
381
|
+
Deleted extra entry x/deleted.json (purge is on)
|
382
|
+
EOM
|
383
|
+
knife('diff --name-status /data_bags').should_succeed ''
|
384
|
+
end
|
385
|
+
end
|
340
386
|
end
|
341
387
|
end
|
342
388
|
|
@@ -396,8 +442,59 @@ EOM
|
|
396
442
|
end
|
397
443
|
end
|
398
444
|
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
445
|
+
when_the_repository 'has a cookbook' do
|
446
|
+
file 'cookbooks/x/metadata.rb', 'version "1.0.0"'
|
447
|
+
file 'cookbooks/x/onlyin1.0.0.rb', 'old_text'
|
448
|
+
|
449
|
+
when_the_chef_server 'has a later version for the cookbook' do
|
450
|
+
cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"', 'onlyin1.0.0.rb' => '' }
|
451
|
+
cookbook 'x', '1.0.1', { 'metadata.rb' => 'version "1.0.1"', 'onlyin1.0.1.rb' => 'hi' }
|
452
|
+
|
453
|
+
it 'knife download /cookbooks/x downloads the latest version' do
|
454
|
+
knife('download --purge /cookbooks/x').should_succeed <<EOM
|
455
|
+
Updated /cookbooks/x/metadata.rb
|
456
|
+
Created /cookbooks/x/onlyin1.0.1.rb
|
457
|
+
Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
|
458
|
+
EOM
|
459
|
+
knife('diff --name-status /cookbooks').should_succeed ''
|
460
|
+
end
|
461
|
+
end
|
462
|
+
|
463
|
+
when_the_chef_server 'has an earlier version for the cookbook' do
|
464
|
+
cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"', 'onlyin1.0.0.rb' => ''}
|
465
|
+
cookbook 'x', '0.9.9', { 'metadata.rb' => 'version "0.9.9"', 'onlyin0.9.9.rb' => 'hi' }
|
466
|
+
it 'knife download /cookbooks/x downloads the updated file' do
|
467
|
+
knife('download --purge /cookbooks/x').should_succeed <<EOM
|
468
|
+
Updated /cookbooks/x/onlyin1.0.0.rb
|
469
|
+
EOM
|
470
|
+
knife('diff --name-status /cookbooks').should_succeed ''
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
474
|
+
when_the_chef_server 'has a later version for the cookbook, and no current version' do
|
475
|
+
cookbook 'x', '1.0.1', { 'metadata.rb' => 'version "1.0.1"', 'onlyin1.0.1.rb' => 'hi' }
|
476
|
+
|
477
|
+
it 'knife download /cookbooks/x downloads the latest version' do
|
478
|
+
knife('download --purge /cookbooks/x').should_succeed <<EOM
|
479
|
+
Updated /cookbooks/x/metadata.rb
|
480
|
+
Created /cookbooks/x/onlyin1.0.1.rb
|
481
|
+
Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
|
482
|
+
EOM
|
483
|
+
knife('diff --name-status /cookbooks').should_succeed ''
|
484
|
+
end
|
485
|
+
end
|
486
|
+
|
487
|
+
when_the_chef_server 'has an earlier version for the cookbook, and no current version' do
|
488
|
+
cookbook 'x', '0.9.9', { 'metadata.rb' => 'version "0.9.9"', 'onlyin0.9.9.rb' => 'hi' }
|
489
|
+
|
490
|
+
it 'knife download /cookbooks/x downloads the old version' do
|
491
|
+
knife('download --purge /cookbooks/x').should_succeed <<EOM
|
492
|
+
Updated /cookbooks/x/metadata.rb
|
493
|
+
Created /cookbooks/x/onlyin0.9.9.rb
|
494
|
+
Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on)
|
495
|
+
EOM
|
496
|
+
knife('diff --name-status /cookbooks').should_succeed ''
|
497
|
+
end
|
498
|
+
end
|
499
|
+
end
|
403
500
|
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'support/integration_helper'
|
2
|
+
require 'chef/knife/raw_essentials'
|
3
|
+
require 'chef/knife/show_essentials'
|
4
|
+
|
5
|
+
describe 'knife raw' do
|
6
|
+
extend IntegrationSupport
|
7
|
+
include KnifeSupport
|
8
|
+
|
9
|
+
when_the_chef_server "has one of each thing" do
|
10
|
+
client 'x', '{}'
|
11
|
+
cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' }
|
12
|
+
data_bag 'x', { 'y' => '{}' }
|
13
|
+
environment 'x', '{}'
|
14
|
+
node 'x', '{}'
|
15
|
+
role 'x', '{}'
|
16
|
+
user 'x', '{}'
|
17
|
+
|
18
|
+
it 'knife raw /nodes/x returns the node', :pending => (RUBY_VERSION < "1.9") do
|
19
|
+
knife('raw /nodes/x').should_succeed <<EOM
|
20
|
+
{
|
21
|
+
"name": "x",
|
22
|
+
"json_class": "Chef::Node",
|
23
|
+
"chef_type": "node",
|
24
|
+
"chef_environment": "_default",
|
25
|
+
"override": {
|
26
|
+
},
|
27
|
+
"normal": {
|
28
|
+
},
|
29
|
+
"default": {
|
30
|
+
},
|
31
|
+
"automatic": {
|
32
|
+
},
|
33
|
+
"run_list": [
|
34
|
+
|
35
|
+
]
|
36
|
+
}
|
37
|
+
EOM
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'knife raw /blarghle returns 404' do
|
41
|
+
knife('raw /blarghle').should_fail(/ERROR: Server responded with error 404 "Not Found"/)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'knife raw -m DELETE /roles/x succeeds', :pending => (RUBY_VERSION < "1.9") do
|
45
|
+
knife('raw -m DELETE /roles/x').should_succeed <<EOM
|
46
|
+
{
|
47
|
+
"name": "x",
|
48
|
+
"description": "",
|
49
|
+
"json_class": "Chef::Role",
|
50
|
+
"chef_type": "role",
|
51
|
+
"default_attributes": {
|
52
|
+
},
|
53
|
+
"override_attributes": {
|
54
|
+
},
|
55
|
+
"run_list": [
|
56
|
+
|
57
|
+
],
|
58
|
+
"env_run_lists": {
|
59
|
+
}
|
60
|
+
}
|
61
|
+
EOM
|
62
|
+
knife('show /roles/x.json').should_fail "ERROR: /roles/x.json: No such file or directory\n"
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'knife raw -m PUT -i blah.txt /roles/x succeeds', :pending => (RUBY_VERSION < "1.9") do
|
66
|
+
Tempfile.open('raw_put_input') do |file|
|
67
|
+
file.write <<EOM
|
68
|
+
{
|
69
|
+
"name": "x",
|
70
|
+
"description": "eek",
|
71
|
+
"json_class": "Chef::Role",
|
72
|
+
"chef_type": "role",
|
73
|
+
"default_attributes": {
|
74
|
+
},
|
75
|
+
"override_attributes": {
|
76
|
+
},
|
77
|
+
"run_list": [
|
78
|
+
|
79
|
+
],
|
80
|
+
"env_run_lists": {
|
81
|
+
}
|
82
|
+
}
|
83
|
+
EOM
|
84
|
+
file.close
|
85
|
+
|
86
|
+
knife("raw -m PUT -i #{file.path} /roles/x").should_succeed <<EOM
|
87
|
+
{
|
88
|
+
"name": "x",
|
89
|
+
"description": "eek",
|
90
|
+
"json_class": "Chef::Role",
|
91
|
+
"chef_type": "role",
|
92
|
+
"default_attributes": {
|
93
|
+
},
|
94
|
+
"override_attributes": {
|
95
|
+
},
|
96
|
+
"run_list": [
|
97
|
+
|
98
|
+
],
|
99
|
+
"env_run_lists": {
|
100
|
+
}
|
101
|
+
}
|
102
|
+
EOM
|
103
|
+
knife('show /roles/x.json').should_succeed <<EOM
|
104
|
+
/roles/x.json:
|
105
|
+
{
|
106
|
+
"name": "x",
|
107
|
+
"description": "eek",
|
108
|
+
"json_class": "Chef::Role",
|
109
|
+
"default_attributes": {
|
110
|
+
},
|
111
|
+
"override_attributes": {
|
112
|
+
},
|
113
|
+
"chef_type": "role",
|
114
|
+
"run_list": [
|
115
|
+
|
116
|
+
],
|
117
|
+
"env_run_lists": {
|
118
|
+
}
|
119
|
+
}
|
120
|
+
EOM
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
it 'knife raw -m POST -i blah.txt /roles succeeds', :pending => (RUBY_VERSION < "1.9") do
|
125
|
+
Tempfile.open('raw_put_input') do |file|
|
126
|
+
file.write <<EOM
|
127
|
+
{
|
128
|
+
"name": "y",
|
129
|
+
"description": "eek",
|
130
|
+
"json_class": "Chef::Role",
|
131
|
+
"chef_type": "role",
|
132
|
+
"default_attributes": {
|
133
|
+
},
|
134
|
+
"override_attributes": {
|
135
|
+
},
|
136
|
+
"run_list": [
|
137
|
+
|
138
|
+
],
|
139
|
+
"env_run_lists": {
|
140
|
+
}
|
141
|
+
}
|
142
|
+
EOM
|
143
|
+
file.close
|
144
|
+
|
145
|
+
knife("raw -m POST -i #{file.path} /roles").should_succeed <<EOM
|
146
|
+
{
|
147
|
+
"uri": "#{ChefZero::RSpec.server.url}/roles/y"
|
148
|
+
}
|
149
|
+
EOM
|
150
|
+
knife('show /roles/y.json').should_succeed <<EOM
|
151
|
+
/roles/y.json:
|
152
|
+
{
|
153
|
+
"name": "y",
|
154
|
+
"description": "eek",
|
155
|
+
"json_class": "Chef::Role",
|
156
|
+
"default_attributes": {
|
157
|
+
},
|
158
|
+
"override_attributes": {
|
159
|
+
},
|
160
|
+
"chef_type": "role",
|
161
|
+
"run_list": [
|
162
|
+
|
163
|
+
],
|
164
|
+
"env_run_lists": {
|
165
|
+
}
|
166
|
+
}
|
167
|
+
EOM
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require 'support/integration_helper'
|
2
|
+
require 'chef/knife/show_essentials'
|
3
|
+
|
4
|
+
describe 'knife show' do
|
5
|
+
extend IntegrationSupport
|
6
|
+
include KnifeSupport
|
7
|
+
|
8
|
+
when_the_chef_server "has one of each thing" do
|
9
|
+
client 'x', '{}'
|
10
|
+
cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' }
|
11
|
+
data_bag 'x', { 'y' => '{}' }
|
12
|
+
environment 'x', '{}'
|
13
|
+
node 'x', '{}'
|
14
|
+
role 'x', '{}'
|
15
|
+
user 'x', '{}'
|
16
|
+
|
17
|
+
when_the_repository 'also has one of each thing' do
|
18
|
+
file 'clients/x.json', { 'foo' => 'bar' }
|
19
|
+
file 'cookbooks/x/metadata.rb', 'version "1.0.1"'
|
20
|
+
file 'data_bags/x/y.json', { 'foo' => 'bar' }
|
21
|
+
file 'environments/_default.json', { 'foo' => 'bar' }
|
22
|
+
file 'environments/x.json', { 'foo' => 'bar' }
|
23
|
+
file 'nodes/x.json', { 'foo' => 'bar' }
|
24
|
+
file 'roles/x.json', { 'foo' => 'bar' }
|
25
|
+
file 'users/x.json', { 'foo' => 'bar' }
|
26
|
+
|
27
|
+
it 'knife show /cookbooks/x/metadata.rb shows the remote version' do
|
28
|
+
knife('show /cookbooks/x/metadata.rb').should_succeed <<EOM
|
29
|
+
/cookbooks/x/metadata.rb:
|
30
|
+
version "1.0.0"
|
31
|
+
EOM
|
32
|
+
end
|
33
|
+
it 'knife show --local /cookbooks/x/metadata.rb shows the local version' do
|
34
|
+
knife('show --local /cookbooks/x/metadata.rb').should_succeed <<EOM
|
35
|
+
/cookbooks/x/metadata.rb:
|
36
|
+
version "1.0.1"
|
37
|
+
EOM
|
38
|
+
end
|
39
|
+
it 'knife show /data_bags/x/y.json shows the remote version' do
|
40
|
+
knife('show /data_bags/x/y.json').should_succeed <<EOM
|
41
|
+
/data_bags/x/y.json:
|
42
|
+
{
|
43
|
+
"id": "y"
|
44
|
+
}
|
45
|
+
EOM
|
46
|
+
end
|
47
|
+
it 'knife show --local /data_bags/x/y.json shows the local version' do
|
48
|
+
knife('show --local /data_bags/x/y.json').should_succeed <<EOM
|
49
|
+
/data_bags/x/y.json:
|
50
|
+
{
|
51
|
+
"foo": "bar"
|
52
|
+
}
|
53
|
+
EOM
|
54
|
+
end
|
55
|
+
it 'knife show /environments/x.json shows the remote version', :pending => (RUBY_VERSION < "1.9") do
|
56
|
+
knife('show /environments/x.json').should_succeed <<EOM
|
57
|
+
/environments/x.json:
|
58
|
+
{
|
59
|
+
"name": "x",
|
60
|
+
"description": "",
|
61
|
+
"cookbook_versions": {
|
62
|
+
},
|
63
|
+
"json_class": "Chef::Environment",
|
64
|
+
"chef_type": "environment",
|
65
|
+
"default_attributes": {
|
66
|
+
},
|
67
|
+
"override_attributes": {
|
68
|
+
}
|
69
|
+
}
|
70
|
+
EOM
|
71
|
+
end
|
72
|
+
it 'knife show --local /environments/x.json shows the local version' do
|
73
|
+
knife('show --local /environments/x.json').should_succeed <<EOM
|
74
|
+
/environments/x.json:
|
75
|
+
{
|
76
|
+
"foo": "bar"
|
77
|
+
}
|
78
|
+
EOM
|
79
|
+
end
|
80
|
+
it 'knife show /roles/x.json shows the remote version', :pending => (RUBY_VERSION < "1.9") do
|
81
|
+
knife('show /roles/x.json').should_succeed <<EOM
|
82
|
+
/roles/x.json:
|
83
|
+
{
|
84
|
+
"name": "x",
|
85
|
+
"description": "",
|
86
|
+
"json_class": "Chef::Role",
|
87
|
+
"default_attributes": {
|
88
|
+
},
|
89
|
+
"override_attributes": {
|
90
|
+
},
|
91
|
+
"chef_type": "role",
|
92
|
+
"run_list": [
|
93
|
+
|
94
|
+
],
|
95
|
+
"env_run_lists": {
|
96
|
+
}
|
97
|
+
}
|
98
|
+
EOM
|
99
|
+
end
|
100
|
+
it 'knife show --local /roles/x.json shows the local version' do
|
101
|
+
knife('show --local /roles/x.json').should_succeed <<EOM
|
102
|
+
/roles/x.json:
|
103
|
+
{
|
104
|
+
"foo": "bar"
|
105
|
+
}
|
106
|
+
EOM
|
107
|
+
end
|
108
|
+
# show directory
|
109
|
+
it 'knife show /data_bags/x fails' do
|
110
|
+
knife('show /data_bags/x').should_fail "ERROR: /data_bags/x: is a directory\n"
|
111
|
+
end
|
112
|
+
it 'knife show --local /data_bags/x fails' do
|
113
|
+
knife('show --local /data_bags/x').should_fail "ERROR: /data_bags/x: is a directory\n"
|
114
|
+
end
|
115
|
+
# show nonexistent file
|
116
|
+
it 'knife show /environments/nonexistent.json fails' do
|
117
|
+
knife('show /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n"
|
118
|
+
end
|
119
|
+
it 'knife show --local /environments/nonexistent.json fails' do
|
120
|
+
knife('show --local /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|