Skip to content

Commit

Permalink
Drop the Interface#can_be_renamed? method
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Aug 29, 2019
1 parent 3cc5d94 commit d2a8c51
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 59 deletions.
9 changes: 0 additions & 9 deletions src/lib/y2network/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,6 @@ def rename(new_name, mechanism)
@renaming_mechanism = mechanism
end

# Determines whether the interface can be renamed
#
# An interface can be renamed if it has a MAC address or a Bus ID.
#
# @return [Boolean]
def can_be_renamed?
hardware && !(hardware.mac.nil? && hardware.busid.nil?)
end

private

def system_config(name)
Expand Down
9 changes: 0 additions & 9 deletions src/lib/y2network/virtual_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,5 @@ class VirtualInterface < Interface
def self.from_connection(name, conn)
new(name, type: conn.type)
end

# Determines whether the interface can be renamed
#
# A virtual interface can always be renamed.
#
# @return [Boolean]
def can_be_renamed?
true
end
end
end
32 changes: 0 additions & 32 deletions test/y2network/interface_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,4 @@
expect(interface.drivers).to eq([driver])
end
end

describe "#can_be_renamed?" do
let(:mac) { nil }
let(:busid) { nil }
let(:hwinfo) { instance_double(Y2Network::Hwinfo, mac: mac, busid: busid) }

before do
allow(interface).to receive(:hardware).and_return(hwinfo)
end

context "when no MAC or Bus ID information is available" do
it "returns false" do
expect(interface.can_be_renamed?).to eq(false)
end
end

context "when the MAC address is present" do
let(:mac) { "01:23:45:67:89:ab" }

it "returns true" do
expect(interface.can_be_renamed?).to eq(true)
end
end

context "when the Bus ID is present" do
let(:busid) { "0000:08:00.0" }

it "returns true" do
expect(interface.can_be_renamed?).to eq(true)
end
end
end
end
6 changes: 0 additions & 6 deletions test/y2network/virtual_interface_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,4 @@

describe Y2Network::VirtualInterface do
subject(:interface) { described_class.new("br0") }

describe "#can_be_renamed?" do
it "returns true" do
expect(interface.can_be_renamed?).to eq(true)
end
end
end
4 changes: 1 addition & 3 deletions test/y2network/widgets/udev_rules_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
describe Y2Network::Widgets::UdevRules do
subject { described_class.new(builder) }

let(:builder) do
instance_double(Y2Network::InterfaceConfigBuilder, interface: double(can_be_renamed?: true))
end
let(:builder) { instance_double(Y2Network::InterfaceConfigBuilder) }

before do
allow(Yast::LanItems).to receive(:current_udev_name).and_return("hell666")
Expand Down

0 comments on commit d2a8c51

Please sign in to comment.