diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-04 08:35:04 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-04 08:35:04 -0800 |
commit | 938c37c2dd5bff3b888540ae1ae4d2e51b3208d8 (patch) | |
tree | 2ee587d74840857a1aaffc09692781d64ebd85ef /spec/unit/provider/git_spec.rb | |
parent | dfeb0a2f8888ea8e1f1860e3da7ad7a1a4dac56f (diff) | |
download | chef-lcg/whitespace-style.tar.gz |
whitespace fixeslcg/whitespace-style
5533 Style/SpaceInsideHashLiteralBraces
2619 Style/SpaceAroundOperators
2288 Style/EmptyLinesAroundBlockBody
2012 Style/SpaceInsideBlockBraces
1444 Style/AlignHash
1395 Style/SpaceAfterComma
1382 Style/SpaceAroundEqualsInParameterDefault
800 Style/EmptyLinesAroundClassBody
396 Style/IndentationConsistency
354 Style/ExtraSpacing
310 Style/SpaceBeforeBlockBraces
309 Style/EmptyLines
304 Style/TrailingWhitespace
241 Style/MultilineOperationIndentation
230 Style/TrailingBlankLines
219 Style/EmptyLinesAroundModuleBody
212 Style/IndentHash
147 Style/IndentationWidth
120 Style/EmptyLineBetweenDefs
107 Style/SpaceAroundBlockParameters
63 Style/EmptyLinesAroundMethodBody
29 Style/EmptyLinesAroundAccessModifier
1 Style/RescueEnsureAlignment
Diffstat (limited to 'spec/unit/provider/git_spec.rb')
-rw-r--r-- | spec/unit/provider/git_spec.rb | 83 |
1 files changed, 39 insertions, 44 deletions
diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index 8c55875ce7..8bcb2a8864 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -16,10 +16,8 @@ # limitations under the License. # - require "spec_helper" describe Chef::Provider::Git do - before(:each) do allow(STDOUT).to receive(:tty?).and_return(true) @original_log_level = Chef::Log.level @@ -44,7 +42,6 @@ describe Chef::Provider::Git do end context "determining the revision of the currently deployed checkout" do - before do @stdout = double("standard out") @stderr = double("standard error") @@ -59,7 +56,7 @@ describe Chef::Provider::Git do it "determines the current revision when there is one" do expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) @stdout = "9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\n" - expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", {:cwd => "/my/deploy/dir", :returns => [0,128]}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", { :cwd => "/my/deploy/dir", :returns => [0, 128] }).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.find_current_revision).to eql("9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13") end @@ -67,7 +64,7 @@ describe Chef::Provider::Git do expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) @stderr = "fatal: Not a git repository (or any of the parent directories): .git" @stdout = "" - expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", :cwd => "/my/deploy/dir", :returns => [0,128]).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr)) + expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", :cwd => "/my/deploy/dir", :returns => [0, 128]).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr)) expect(@provider.find_current_revision).to be_nil end end @@ -85,7 +82,6 @@ describe Chef::Provider::Git do end context "resolving revisions to a SHA" do - before do @git_ls_remote = "git ls-remote \"git://github.com/opscode/chef.git\" " end @@ -98,7 +94,7 @@ describe Chef::Provider::Git do @resource.revision "v1.0" @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -107,7 +103,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0^{}\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53") end @@ -116,7 +112,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/releases/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -125,7 +121,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.target_revision).to eql("663c22a5e41f5ae3193460cca044ed1435029f53") end @@ -134,7 +130,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.1\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -144,7 +140,7 @@ describe Chef::Provider::Git do "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + "805c22a5e41f5ae3193460cca044ed1435029f53\trefs/pulls/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/pulls/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.target_revision).to eql("805c22a5e41f5ae3193460cca044ed1435029f53") end @@ -153,7 +149,7 @@ describe Chef::Provider::Git do @stdout = ("d03c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" + "663c22a5e41f5ae3193460cca044ed1435029f53\trefs/tags/v1.0\n" + "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/v1.0\n") - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"refs/heads/v1.0*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.target_revision).to eql("503c22a5e41f5ae3193460cca044ed1435029f53") end @@ -162,7 +158,7 @@ describe Chef::Provider::Git do @provider.action = :checkout @provider.define_resource_requirements allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - expect {@provider.process_resource_requirements}.to raise_error(Chef::Exceptions::InvalidRemoteGitReference) + expect { @provider.process_resource_requirements }.to raise_error(Chef::Exceptions::InvalidRemoteGitReference) end it "raises an unresolvable git reference error if the revision can't be resolved to any revision and assertions are run" do @@ -182,7 +178,7 @@ describe Chef::Provider::Git do it "does not raise an error when the revision is valid and assertions are run." do @resource.revision "0.8-alpha" @stdout = "503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha\n" - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"0.8-alpha*\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) @provider.action = :checkout allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) @provider.define_resource_requirements @@ -190,7 +186,7 @@ describe Chef::Provider::Git do end it "gives the latest HEAD revision SHA if nothing is specified" do - @stdout =<<-SHAS + @stdout = <<-SHAS 28af684d8460ba4793eda3e7ac238c864a5d029a\tHEAD 503c22a5e41f5ae3193460cca044ed1435029f53\trefs/heads/0.8-alpha 28af684d8460ba4793eda3e7ac238c864a5d029a\trefs/heads/master @@ -207,7 +203,7 @@ b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{} ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package SHAS @resource.revision "" - expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", { :log_tag => "git[web2.0 app]" }).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.target_revision).to eql("28af684d8460ba4793eda3e7ac238c864a5d029a") end end @@ -248,7 +244,7 @@ SHAS end context "with a specific home" do let (:override_home) do - {"HOME" => "/home/masterNinja"} + { "HOME" => "/home/masterNinja" } end let(:overrided_options) do { @@ -275,9 +271,9 @@ SHAS @resource.ssh_wrapper "do_it_this_way.sh" expected_cmd = "git clone \"git://github.com/opscode/chef.git\" \"/Application Support/with/space\"" expect(@provider).to receive(:shell_out!).with(expected_cmd, :user => "deployNinja", - :environment =>{"GIT_SSH"=>"do_it_this_way.sh", - "HOME" => "/home/deployNinja"}, - :log_tag => "git[web2.0 app]") + :environment => { "GIT_SSH" => "do_it_this_way.sh", + "HOME" => "/home/deployNinja" }, + :log_tag => "git[web2.0 app]") @provider.clone end @@ -312,9 +308,9 @@ SHAS it "runs a checkout command with default options" do expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]").ordered + :log_tag => "git[web2.0 app]").ordered expect(@provider).to receive(:shell_out!).with("git checkout deploy", :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]").ordered + :log_tag => "git[web2.0 app]").ordered @provider.checkout end @@ -322,7 +318,7 @@ SHAS @resource.enable_submodules true expected_cmd = "git submodule sync" expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", - :log_tag => "git[web2.0 app]") + :log_tag => "git[web2.0 app]") expected_cmd = "git submodule update --init --recursive" expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") @provider.enable_submodules @@ -336,7 +332,7 @@ SHAS it "runs a sync command with default options" do expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" - expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd=> "/my/deploy/dir", :log_tag => "git[web2.0 app]") + expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]") @provider.fetch_updates end @@ -347,9 +343,9 @@ SHAS expect(@provider).to receive(:setup_remote_tracking_branches).with(@resource.remote, @resource.repository) expected_cmd = "git fetch origin && git fetch origin --tags && git reset --hard d35af14d41ae22b19da05d7d03a0bafc321b244c" expect(@provider).to receive(:shell_out!).with(expected_cmd, :cwd => "/my/deploy/dir", - :user => "whois", :group => "thisis", - :log_tag => "git[web2.0 app]", - :environment=>{"HOME"=>"/home/whois"}) + :user => "whois", :group => "thisis", + :log_tag => "git[web2.0 app]", + :environment => { "HOME" => "/home/whois" }) @provider.fetch_updates end @@ -370,7 +366,6 @@ SHAS end context "configuring remote tracking branches" do - it "checks if a remote with this name already exists" do command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 1 } @@ -378,7 +373,7 @@ SHAS expect(@provider).to receive(:shell_out!).with(expected_command, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]", - :returns => [0,1,2]).and_return(command_response) + :returns => [0, 1, 2]).and_return(command_response) add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(add_remote_command, :cwd => "/my/deploy/dir", @@ -398,15 +393,15 @@ SHAS :log_tag => "git[web2.0 app]", :user => "whois", :group => "thisis", - :environment=>{"HOME"=>"/home/whois"}, - :returns => [0,1,2]).and_return(command_response) + :environment => { "HOME" => "/home/whois" }, + :returns => [0, 1, 2]).and_return(command_response) add_remote_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(add_remote_command, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]", :user => "whois", :group => "thisis", - :environment=>{"HOME"=>"/home/whois"}) + :environment => { "HOME" => "/home/whois" }) @provider.setup_remote_tracking_branches(@resource.remote, @resource.repository) end @@ -418,7 +413,7 @@ SHAS expect(@provider).to receive(:shell_out!).with(check_remote_command, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]", - :returns => [0,1,2]).and_return(command_response) + :returns => [0, 1, 2]).and_return(command_response) expected_command = "git remote add #{@resource.remote} #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(expected_command, :cwd => "/my/deploy/dir", @@ -436,7 +431,7 @@ SHAS expect(@provider).to receive(:shell_out!).with(check_remote_command, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]", - :returns => [0,1,2]).and_return(command_response) + :returns => [0, 1, 2]).and_return(command_response) expected_command = "git config --replace-all remote.#{@resource.remote}.url #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(expected_command, :cwd => "/my/deploy/dir", @@ -452,7 +447,7 @@ SHAS expect(@provider).to receive(:shell_out!).with(check_remote_command, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]", - :returns => [0,1,2]).and_return(command_response) + :returns => [0, 1, 2]).and_return(command_response) unexpected_command = "git config --replace-all remote.#{@resource.remote}.url #{@resource.repository}" expect(@provider).not_to receive(:shell_out!).with(unexpected_command, :cwd => "/my/deploy/dir", @@ -467,7 +462,7 @@ SHAS expect(@provider).to receive(:shell_out!).with(check_remote_command, :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]", - :returns => [0,1,2]).and_return(command_response) + :returns => [0, 1, 2]).and_return(command_response) expected_command = "git config --replace-all remote.#{@resource.remote}.url #{@resource.repository}" expect(@provider).to receive(:shell_out!).with(expected_command, :cwd => "/my/deploy/dir", @@ -479,7 +474,7 @@ SHAS it "raises an error if the git clone command would fail because the enclosing directory doesn't exist" do allow(@provider).to receive(:shell_out!) - expect {@provider.run_action(:sync)}.to raise_error(Chef::Exceptions::MissingParentDirectory) + expect { @provider.run_action(:sync) }.to raise_error(Chef::Exceptions::MissingParentDirectory) end it "does a checkout by cloning the repo and then enabling submodules" do @@ -488,7 +483,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".",".."]) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", ".."]) expect(@provider).to receive(:clone) expect(@provider).to receive(:checkout) expect(@provider).to receive(:enable_submodules) @@ -504,7 +499,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".",".."]) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", ".."]) @resource.enable_checkout false expect(@provider).to receive(:clone) @@ -519,7 +514,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(false) allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(false) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(["..","."]) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(["..", "."]) expect(@provider).to receive(:clone) expect(@provider).to receive(:checkout) expect(@provider).to receive(:enable_submodules) @@ -534,7 +529,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".","..","foo","bar"]) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".", "..", "foo", "bar"]) expect(@provider).not_to receive(:clone) expect(@provider).not_to receive(:checkout) expect(@provider).not_to receive(:enable_submodules) @@ -606,8 +601,8 @@ SHAS describe "calling add_remotes" do it "adds a new remote for each entry in additional remotes hash" do - @resource.additional_remotes({:opscode => "opscode_repo_url", - :another_repo => "some_other_repo_url"}) + @resource.additional_remotes({ :opscode => "opscode_repo_url", + :another_repo => "some_other_repo_url" }) allow(STDOUT).to receive(:tty?).and_return(false) command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 0 } |