Skip to content

Commit

Permalink
fix appending hostname in Host#Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Oct 14, 2016
1 parent 8eb9bfa commit 72281b1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/modules/Host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def Update(oldhn, newhn, ip)
if hosts.empty?
@hosts.add_entry(ip, newhn, nick)
else
canonical, *aliases = hosts.last
canonical, *aliases = hosts.last.split(" ")
aliases << newhn
aliases.concat(nick)
@hosts.set_entry(ip, canonical, aliases)
Expand Down
10 changes: 10 additions & 0 deletions test/host_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,15 @@
expect(content.lines).to include("10.100.128.72 pepa pepa2\n")
expect(content.lines).to include("10.0.0.42\tnewname.suse.cz newname\n")
end

it "adds hostname as alias if ip have already its entry" do
Yast::Host.Read
Yast::Host.Update("pepa.labs.suse.cz", "newname.suse.cz", "10.100.128.72")
Yast::Host.Write

content = file.content

expect(content.lines).to include("10.100.128.72 pepa pepa2 newname.suse.cz newname\n")
end
end
end

0 comments on commit 72281b1

Please sign in to comment.