-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
guests/linux: Always order discovered network interfaces
- Loading branch information
1 parent
4b1d45b
commit ce3329e
Showing
2 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
test/unit/plugins/guests/linux/cap/network_interfaces_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require_relative "../../../../base" | ||
|
||
describe "VagrantPlugins::GuestLinux::Cap::NetworkInterfaces" do | ||
let(:caps) do | ||
VagrantPlugins::GuestLinux::Plugin | ||
.components | ||
.guest_capabilities[:linux] | ||
end | ||
|
||
let(:machine) { double("machine") } | ||
let(:comm) { VagrantTests::DummyCommunicator::Communicator.new(machine) } | ||
|
||
before do | ||
allow(machine).to receive(:communicate).and_return(comm) | ||
end | ||
|
||
after do | ||
comm.verify_expectations! | ||
end | ||
|
||
describe ".network_interfaces" do | ||
let(:cap){ caps.get(:network_interfaces) } | ||
|
||
it "sorts discovered classic interfaces" do | ||
expect(comm).to receive(:sudo).and_yield(:stdout, "eth1\neth2\neth0") | ||
result = cap.network_interfaces(machine) | ||
expect(result).to eq(["eth0", "eth1", "eth2"]) | ||
end | ||
|
||
it "sorts discovered predictable network interfaces" do | ||
expect(comm).to receive(:sudo).and_yield(:stdout, "enp0s8\nenp0s3\nenp0s5") | ||
result = cap.network_interfaces(machine) | ||
expect(result).to eq(["enp0s3", "enp0s5", "enp0s8"]) | ||
end | ||
|
||
it "sorts discovered classic interfaces naturally" do | ||
expect(comm).to receive(:sudo).and_yield(:stdout, "eth1\neth2\neth12\neth0\neth10") | ||
result = cap.network_interfaces(machine) | ||
expect(result).to eq(["eth0", "eth1", "eth2", "eth10", "eth12"]) | ||
end | ||
|
||
it "sorts discovered predictable network interfaces naturally" do | ||
expect(comm).to receive(:sudo).and_yield(:stdout, "enp0s8\nenp0s3\nenp0s5\nenp0s10\nenp1s3") | ||
result = cap.network_interfaces(machine) | ||
expect(result).to eq(["enp0s3", "enp0s5", "enp0s8", "enp0s10", "enp1s3"]) | ||
end | ||
end | ||
end |
ce3329e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit resulted in #8646