Sha256: 8d03e6692cb31e4342c92bfe4c17eab22286fc81863c68294aa1af35a27a6060

Contents?: true

Size: 1.67 KB

Versions: 7

Compression:

Stored size: 1.67 KB

Contents

require 'test_helper'
require 'support/kitchen_helper'

require 'chef/knife/bootstrap_solo'
require 'chef/knife/solo_bootstrap'

class KnifeBootstrapTest < TestCase
  include KitchenHelper

  def test_includes_solo_options
    assert Chef::Knife::Bootstrap.options.include?(:solo)
  end

  def test_runs_solo_bootstrap_if_specified_as_option
    Chef::Config.knife[:solo] = false
    Chef::Knife::SoloBootstrap.any_instance.expects(:run)
    Chef::Knife::Bootstrap.any_instance.expects(:run_with_chef_client).never
    in_kitchen do
      command("somehost", "--solo").run
    end
  end

  def test_runs_solo_bootstrap_if_specified_as_chef_configuration
    Chef::Config.knife[:solo] = true
    Chef::Knife::SoloBootstrap.any_instance.expects(:run)
    Chef::Knife::Bootstrap.any_instance.expects(:run_with_chef_client).never
    in_kitchen do
      command("somehost").run
    end
  end

  def test_runs_original_bootstrap_by_default
    Chef::Config.knife[:solo] = false
    Chef::Knife::SoloBootstrap.any_instance.expects(:run).never
    Chef::Knife::Bootstrap.any_instance.expects(:run_with_chef_client)
    in_kitchen do
      command("somehost").run
    end
  end

  def test_runs_original_bootstrap_if_specified_as_option
    Chef::Config.knife[:solo] = true
    Chef::Knife::SoloBootstrap.any_instance.expects(:run).never
    Chef::Knife::Bootstrap.any_instance.expects(:run_with_chef_client)
    in_kitchen do
      command("somehost", "--no-solo").run
    end
  end

  def test_barks_without_atleast_a_hostname
    cmd = command("--solo")
    cmd.ui.expects(:error)
    in_kitchen do
      assert_exits cmd
    end
  end

  def command(*args)
    knife_command(Chef::Knife::Bootstrap, *args)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
knife-solo-0.7.0 test/knife_bootstrap_test.rb
knife-solo-0.7.0.pre3 test/knife_bootstrap_test.rb
knife-solo-0.7.0.pre2 test/knife_bootstrap_test.rb
knife-solo-0.7.0.pre test/knife_bootstrap_test.rb
knife-solo-0.6.0 test/knife_bootstrap_test.rb
knife-solo-0.5.1 test/knife_bootstrap_test.rb
knife-solo-0.5.0 test/knife_bootstrap_test.rb