diff options
author | Vasiliy Tolstov <v.tolstov@selfip.ru> | 2014-11-19 02:06:55 +0300 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-01-25 13:33:05 -0800 |
commit | 40c4733c78d4522df12ea9af6990aa91b7f7e377 (patch) | |
tree | a6d42ca851e4ea759e27d112866619541ffdd4aa /spec | |
parent | 38ac328723a6221349db78355e741817f2b98618 (diff) | |
download | chef-40c4733c78d4522df12ea9af6990aa91b7f7e377.tar.gz |
try to add tests
Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
Diffstat (limited to 'spec')
-rw-r--r-- | spec/data/recipes.tgz | bin | 0 -> 4120 bytes | |||
-rw-r--r-- | spec/integration/client/client_spec.rb | 56 |
2 files changed, 56 insertions, 0 deletions
diff --git a/spec/data/recipes.tgz b/spec/data/recipes.tgz Binary files differnew file mode 100644 index 0000000000..e5d3e1669a --- /dev/null +++ b/spec/data/recipes.tgz diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index 62660bb852..e49d38dc4e 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -1,9 +1,42 @@ require 'support/shared/integration/integration_helper' require 'chef/mixin/shell_out' +module ChefHTTPShared + 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 + +end + + + describe "chef-client" do include IntegrationSupport include Chef::Mixin::ShellOut + include ChefHTTPShared let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") } @@ -279,4 +312,27 @@ end end end + context "when using recipe-url" do + before(:all) do + start_tiny_server + end + + after(:all) do + stop_tiny_server + end + + it "should complete with success when passed -z and --recipe-url" do + file 'config/client.rb', <<EOM +cookbook_path "#{path_to('cookbooks')}" +EOM + + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", :cwd => chef_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 => chef_dir) + expect(result.exitstatus).to eq(1) + end + end end |