This repository has been archived by the owner on Mar 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 213
/
knife_bootstrap_test.rb
61 lines (52 loc) · 1.67 KB
/
knife_bootstrap_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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