diff options
Diffstat (limited to 'spec/integration/client/client_spec.rb')
-rw-r--r-- | spec/integration/client/client_spec.rb | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index 62660bb852..3475a569b6 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -1,5 +1,34 @@ require 'support/shared/integration/integration_helper' require 'chef/mixin/shell_out' +require 'tiny_server' +require 'tmpdir' + +def recipes_filename + File.join(CHEF_SPEC_DATA, 'recipes.tgz') +end + +def start_tiny_server(server_opts={}) + recipes_size = File::Stat.new(recipes_filename).size + @server = TinyServer::Manager.new(server_opts) + @server.start + @api = TinyServer::API.instance + @api.clear + # + # trivial endpoints + # + # just a normal file + # (expected_content should be uncompressed) + @api.get("/recipes.tgz", 200) { + File.open(recipes_filename, "rb") do |f| + f.read + end + } +end + +def stop_tiny_server + @server.stop + @server = @api = nil +end describe "chef-client" do include IntegrationSupport @@ -279,4 +308,28 @@ end end end + context "when using recipe-url" do + before(:all) do + start_tiny_server + end + + after(:all) do + stop_tiny_server + end + + let(:tmp_dir) { Dir.mktmpdir("recipe-url") } + + it "should complete with success when passed -z and --recipe-url" do + file 'config/client.rb', <<EOM +chef_repo_path "#{tmp_dir}" +EOM + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", :cwd => tmp_dir) + result.error! + end + + it 'should fail when passed --recipe-url and not passed -z' do + result = shell_out("#{chef_client} --recipe-url=http://localhost:9000/recipes.tgz", :cwd => tmp_dir) + expect(result.exitstatus).to eq(1) + end + end end |