|
39 | 39 | allow(command_instance).to receive(:omnibus_install?).and_return true |
40 | 40 | allow(command_instance).to receive(:omnibus_embedded_bin_dir).and_return(omnibus_embedded_bin_dir) |
41 | 41 | allow(command_instance).to receive(:omnibus_bin_dir).and_return(omnibus_bin_dir) |
| 42 | + allow(command_instance).to receive(:get_product_info).and_return(ChefCLI::Dist::PRODUCT) |
42 | 43 | command_instance.ui = ui |
43 | 44 | end |
44 | 45 |
|
|
81 | 82 | end |
82 | 83 | end |
83 | 84 | end |
| 85 | + |
| 86 | + describe "when running from a Habitat install (Chef DKE)" do |
| 87 | + before do |
| 88 | + allow(command_instance).to receive(:habitat_chef_dke?).and_return true |
| 89 | + allow(command_instance).to receive(:omnibus_install?).and_return false |
| 90 | + allow(command_instance).to receive(:get_product_info).and_return(ChefCLI::Dist::CHEF_DK_CLI_PACKAGE) |
| 91 | + allow(command_instance).to receive(:workstation_info).and_return({ |
| 92 | + "Version" => ChefCLI::VERSION, |
| 93 | + "Home" => "/hab/pkgs/chef/chef-dke", |
| 94 | + "Install Directory" => "/hab/pkgs/chef/chef-dke/#{ChefCLI::VERSION}", |
| 95 | + "Policyfile Config" => "/hab/pkgs/chef/chef-dke/#{ChefCLI::VERSION}/config/policyfile.rb" |
| 96 | + }) |
| 97 | + command_instance.ui = ui |
| 98 | + end |
| 99 | + |
| 100 | + describe "and the env command is run" do |
| 101 | + let(:yaml) { YAML.load(ui.output) } |
| 102 | + before :each do |
| 103 | + run_command |
| 104 | + end |
| 105 | + |
| 106 | + it "output should be valid yaml" do |
| 107 | + expect { yaml }.not_to raise_error |
| 108 | + end |
| 109 | + |
| 110 | + it "should include correct Habitat Chef-DKE version info" do |
| 111 | + expect(yaml).to have_key ChefCLI::Dist::CHEF_DK_CLI_PACKAGE |
| 112 | + expect(yaml[ChefCLI::Dist::CHEF_DK_CLI_PACKAGE]["Version"]).to eql ChefCLI::VERSION |
| 113 | + expect(yaml[ChefCLI::Dist::CHEF_DK_CLI_PACKAGE]["Home"]).to eql "/hab/pkgs/chef/chef-dke" |
| 114 | + expect(yaml[ChefCLI::Dist::CHEF_DK_CLI_PACKAGE]["Install Directory"]).to eql "/hab/pkgs/chef/chef-dke/#{ChefCLI::VERSION}" |
| 115 | + expect(yaml[ChefCLI::Dist::CHEF_DK_CLI_PACKAGE]["Policyfile Config"]).to eql "/hab/pkgs/chef/chef-dke/#{ChefCLI::VERSION}/config/policyfile.rb" |
| 116 | + end |
| 117 | + end |
| 118 | + end |
| 119 | + |
| 120 | + describe "when running from a Habitat install (Standalone)" do |
| 121 | + before do |
| 122 | + allow(command_instance).to receive(:habitat_standalone?).and_return true |
| 123 | + allow(command_instance).to receive(:omnibus_install?).and_return false |
| 124 | + allow(command_instance).to receive(:get_product_info).and_return(ChefCLI::Dist::CHEF_CLI_PACKAGE) |
| 125 | + allow(command_instance).to receive(:workstation_info).and_return({ |
| 126 | + "Version" => ChefCLI::VERSION, |
| 127 | + "Home" => "/hab/pkgs/chef/chef-cli", |
| 128 | + "Install Directory" => "/hab/pkgs/chef/chef-cli/#{ChefCLI::VERSION}", |
| 129 | + "Policyfile Config" => "/hab/pkgs/chef/chef-cli/#{ChefCLI::VERSION}/config/policyfile.rb" |
| 130 | + }) |
| 131 | + command_instance.ui = ui |
| 132 | + end |
| 133 | + |
| 134 | + describe "and the env command is run" do |
| 135 | + let(:yaml) { YAML.load(ui.output) } |
| 136 | + before :each do |
| 137 | + run_command |
| 138 | + end |
| 139 | + |
| 140 | + it "output should be valid yaml" do |
| 141 | + expect { yaml }.not_to raise_error |
| 142 | + end |
| 143 | + |
| 144 | + it "should include correct Habitat Standalone version info" do |
| 145 | + expect(yaml).to have_key ChefCLI::Dist::CHEF_CLI_PACKAGE |
| 146 | + expect(yaml[ChefCLI::Dist::CHEF_CLI_PACKAGE]["Version"]).to eql ChefCLI::VERSION |
| 147 | + expect(yaml[ChefCLI::Dist::CHEF_CLI_PACKAGE]["Home"]).to eql "/hab/pkgs/chef/chef-cli" |
| 148 | + expect(yaml[ChefCLI::Dist::CHEF_CLI_PACKAGE]["Install Directory"]).to eql "/hab/pkgs/chef/chef-cli/#{ChefCLI::VERSION}" |
| 149 | + expect(yaml[ChefCLI::Dist::CHEF_CLI_PACKAGE]["Policyfile Config"]).to eql "/hab/pkgs/chef/chef-cli/#{ChefCLI::VERSION}/config/policyfile.rb" |
| 150 | + end |
| 151 | + end |
| 152 | + end |
| 153 | + |
84 | 154 | def run_command |
85 | 155 | command_instance.run_with_default_options(false, command_options) |
86 | 156 | end |
|
0 commit comments