|
1 | 1 | describe ManageIQ::Providers::Vmware::InfraManager::Host do |
2 | | - before(:each) do |
3 | | - @host = FactoryBot.create(:host_vmware) |
4 | | - end |
| 2 | + let(:ems) { FactoryBot.create(:ems_vmware) } |
| 3 | + let(:host) { FactoryBot.create(:host_vmware, :ext_management_system => ems) } |
5 | 4 |
|
6 | 5 | context "#reserve_next_available_vnc_port" do |
7 | 6 | context "without EMS defaults set" do |
8 | | - before(:each) do |
9 | | - @ems = FactoryBot.create(:ems_vmware, :host_default_vnc_port_start => nil, :host_default_vnc_port_end => nil) |
10 | | - @host.ext_management_system = @ems |
11 | | - end |
| 7 | + let(:ems) { FactoryBot.create(:ems_vmware, :host_default_vnc_port_start => nil, :host_default_vnc_port_end => nil) } |
12 | 8 |
|
13 | 9 | it "normal case" do |
14 | | - @host.update(:next_available_vnc_port => 5901) |
| 10 | + host.update(:next_available_vnc_port => 5901) |
15 | 11 |
|
16 | | - expect(@host.reserve_next_available_vnc_port).to eq(5901) |
17 | | - expect(@host.next_available_vnc_port).to eq(5902) |
| 12 | + expect(host.reserve_next_available_vnc_port).to eq(5901) |
| 13 | + expect(host.next_available_vnc_port).to eq(5902) |
18 | 14 | end |
19 | 15 |
|
20 | 16 | it "with last value of nil" do |
21 | | - @host.update(:next_available_vnc_port => nil) |
| 17 | + host.update(:next_available_vnc_port => nil) |
22 | 18 |
|
23 | | - expect(@host.reserve_next_available_vnc_port).to eq(5900) |
24 | | - expect(@host.next_available_vnc_port).to eq(5901) |
| 19 | + expect(host.reserve_next_available_vnc_port).to eq(5900) |
| 20 | + expect(host.next_available_vnc_port).to eq(5901) |
25 | 21 | end |
26 | 22 |
|
27 | 23 | it "with last value at end of range" do |
28 | | - @host.update(:next_available_vnc_port => 5999) |
| 24 | + host.update(:next_available_vnc_port => 5999) |
29 | 25 |
|
30 | | - expect(@host.reserve_next_available_vnc_port).to eq(5999) |
31 | | - expect(@host.next_available_vnc_port).to eq(5900) |
| 26 | + expect(host.reserve_next_available_vnc_port).to eq(5999) |
| 27 | + expect(host.next_available_vnc_port).to eq(5900) |
32 | 28 | end |
33 | 29 |
|
34 | 30 | it "with last value before start of range" do |
35 | | - @host.update(:next_available_vnc_port => 5899) |
| 31 | + host.update(:next_available_vnc_port => 5899) |
36 | 32 |
|
37 | | - expect(@host.reserve_next_available_vnc_port).to eq(5900) |
38 | | - expect(@host.next_available_vnc_port).to eq(5901) |
| 33 | + expect(host.reserve_next_available_vnc_port).to eq(5900) |
| 34 | + expect(host.next_available_vnc_port).to eq(5901) |
39 | 35 | end |
40 | 36 |
|
41 | 37 | it "with last value after end of range" do |
42 | | - @host.update(:next_available_vnc_port => 6000) |
| 38 | + host.update(:next_available_vnc_port => 6000) |
43 | 39 |
|
44 | | - expect(@host.reserve_next_available_vnc_port).to eq(5900) |
45 | | - expect(@host.next_available_vnc_port).to eq(5901) |
| 40 | + expect(host.reserve_next_available_vnc_port).to eq(5900) |
| 41 | + expect(host.next_available_vnc_port).to eq(5901) |
46 | 42 | end |
47 | 43 | end |
48 | 44 |
|
49 | 45 | context "with EMS defaults set" do |
50 | | - before(:each) do |
51 | | - @ems = FactoryBot.create(:ems_vmware, :host_default_vnc_port_start => 5925, :host_default_vnc_port_end => 5930) |
52 | | - @host.ext_management_system = @ems |
53 | | - end |
| 46 | + let(:ems) { FactoryBot.create(:ems_vmware, :host_default_vnc_port_start => 5925, :host_default_vnc_port_end => 5930) } |
54 | 47 |
|
55 | 48 | it "normal case" do |
56 | | - @host.update(:next_available_vnc_port => 5926) |
| 49 | + host.update(:next_available_vnc_port => 5926) |
57 | 50 |
|
58 | | - expect(@host.reserve_next_available_vnc_port).to eq(5926) |
59 | | - expect(@host.next_available_vnc_port).to eq(5927) |
| 51 | + expect(host.reserve_next_available_vnc_port).to eq(5926) |
| 52 | + expect(host.next_available_vnc_port).to eq(5927) |
60 | 53 | end |
61 | 54 |
|
62 | 55 | it "with last value of nil" do |
63 | | - @host.update(:next_available_vnc_port => nil) |
| 56 | + host.update(:next_available_vnc_port => nil) |
64 | 57 |
|
65 | | - expect(@host.reserve_next_available_vnc_port).to eq(5925) |
66 | | - expect(@host.next_available_vnc_port).to eq(5926) |
| 58 | + expect(host.reserve_next_available_vnc_port).to eq(5925) |
| 59 | + expect(host.next_available_vnc_port).to eq(5926) |
67 | 60 | end |
68 | 61 |
|
69 | 62 | it "with last value at end of range" do |
70 | | - @host.update(:next_available_vnc_port => 5930) |
| 63 | + host.update(:next_available_vnc_port => 5930) |
71 | 64 |
|
72 | | - expect(@host.reserve_next_available_vnc_port).to eq(5930) |
73 | | - expect(@host.next_available_vnc_port).to eq(5925) |
| 65 | + expect(host.reserve_next_available_vnc_port).to eq(5930) |
| 66 | + expect(host.next_available_vnc_port).to eq(5925) |
74 | 67 | end |
75 | 68 |
|
76 | 69 | it "with last value before start of range" do |
77 | | - @host.update(:next_available_vnc_port => 5924) |
| 70 | + host.update(:next_available_vnc_port => 5924) |
78 | 71 |
|
79 | | - expect(@host.reserve_next_available_vnc_port).to eq(5925) |
80 | | - expect(@host.next_available_vnc_port).to eq(5926) |
| 72 | + expect(host.reserve_next_available_vnc_port).to eq(5925) |
| 73 | + expect(host.next_available_vnc_port).to eq(5926) |
81 | 74 | end |
82 | 75 |
|
83 | 76 | it "with last value after end of range" do |
84 | | - @host.update(:next_available_vnc_port => 5931) |
| 77 | + host.update(:next_available_vnc_port => 5931) |
85 | 78 |
|
86 | | - expect(@host.reserve_next_available_vnc_port).to eq(5925) |
87 | | - expect(@host.next_available_vnc_port).to eq(5926) |
| 79 | + expect(host.reserve_next_available_vnc_port).to eq(5925) |
| 80 | + expect(host.next_available_vnc_port).to eq(5926) |
88 | 81 | end |
89 | 82 | end |
90 | 83 | end |
|
0 commit comments