Skip to content

Commit

Permalink
Updated testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Nov 26, 2018
1 parent 40b810f commit 6049f4f
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/address_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,23 @@ def initialize
let(:initial_hostname) { "initial.hostname.com" }
let(:new_hostname) { "new.hostname.com" }

it "drops old /etc/hosts record if hostname was changed" do
before(:each) do
allow(Yast::LanItems)
.to receive(:ipaddr)
.and_return(ip)
allow(subject)
.to receive(:initial_hostname)
.and_return(initial_hostname)
allow(Yast::Host)
.to receive(:names)
.and_call_original
allow(Yast::Host)
.to receive(:names)
.with(ip)
.and_return(["#{initial_hostname} custom-name"])
end

it "drops old /etc/hosts record if hostname was changed" do
expect(Yast::Host)
.to receive(:remove_ip)
.with(ip)
Expand All @@ -150,6 +159,15 @@ def initialize

subject.send(:update_hostname, ip, new_hostname)
end

it "keeps names untouched when only the ip was changed" do
new_ip = "2.2.2.2"

original_names = Yast::Host.names(ip)
subject.send(:update_hostname, new_ip, initial_hostname)

expect(Yast::Host.names(new_ip)).to eql original_names
end
end

end

0 comments on commit 6049f4f

Please sign in to comment.