Skip to content

Commit

Permalink
Fix and enable some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Jul 10, 2017
1 parent 216b059 commit dc8ce45
Showing 1 changed file with 29 additions and 24 deletions.
53 changes: 29 additions & 24 deletions test/stage1_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,16 @@
Yast.import "Arch"
Yast.import "BootStorage"

xdescribe Bootloader::Stage1 do
describe Bootloader::Stage1 do
before do
# simple mock getting disks from partition as it need initialized libstorage
allow(subject).to receive(:can_use_boot?).and_return(true)
mock_disk_partition
# mock_disk_partition
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")

# nasty hack to allow call of uninitialized libstorage as we do not want
# to overmock Yast::Storage.GetDiskPartitionTg call
Yast::Storage.instance_variable_set(:@sint, double(getPartitionPrefix: ""))
end

describe "#propose" do
it "sets devices to proposed locations" do
xit "sets devices to proposed locations" do
target_map_stub("storage_mdraid.yaml")
allow(Yast::BootStorage).to receive(:possible_locations_for_stage1)
.and_return(["/dev/vda", "/dev/vda1"])
Expand All @@ -33,7 +29,7 @@
expect(subject.devices).to eq ["/dev/vda"]
end

it "sets underlaying disks for md raid setup" do
xit "sets underlaying disks for md raid setup" do
allow(Bootloader::Stage1Device).to receive(:new).and_call_original
target_map_stub("storage_mdraid.yaml")

Expand All @@ -49,7 +45,7 @@
expect(subject.mbr?).to eq true
end

it "do not set generic_mbr if proposed boot from mbr" do
xit "do not set generic_mbr if proposed boot from mbr" do
allow(Bootloader::Stage1Device).to receive(:new).and_call_original
target_map_stub("storage_mdraid.yaml")

Expand All @@ -64,25 +60,37 @@
end

context "on ppc64" do
let(:sda) { double("Y2Storage::Disk", gpt?: true) }
let(:sdb) { double("Y2Storage::Disk", gpt?: true) }
let(:sdc) { double("Y2Storage::Disk", gpt?: true) }

let(:sda1) do
double("Y2Storage::Partition", name: "/dev/sda1", exists_in_probed?: true, partitionable: sda)
end

let(:sdb1) do
double("Y2Storage::Partition", name: "/dev/sdb1", exists_in_probed?: true, partitionable: sdb)
end

let(:sdc1) do
double("Y2Storage::Partition", name: "/dev/sdc1", exists_in_probed?: true, partitionable: sdc)
end

before do
allow(Yast::Arch).to receive(:architecture).and_return("ppc64")

object_double(
"Yast::BootStorage",
prep_partitions: ["/dev/sda1", "/dev/sdb1", "/dev/sdc1"],
prep_partitions: [sda1, sdb1, sdc1],
detect_disks: nil,
disk_with_boot_partition: "/dev/sdb"
disk_with_boot_partition: sdb
).as_stubbed_const

subject.propose

allow(Yast::Storage).to receive(:GetPartition).and_return({})
end

it "tries to use newly created partition at first" do
expect(Yast::Storage).to receive(:GetPartition).with(anything, "/dev/sdc1")
.and_return("create" => true)

allow(sdc1).to receive(:exists_in_probed?).and_return(false)
subject.propose

expect(subject.devices).to eq(["/dev/sdc1"])
Expand All @@ -99,7 +107,7 @@
expect(subject.devices).to eq(["/dev/sda1"])
end

it "sets udev link for device" do
xit "sets udev link for device" do
expect(Yast::Storage).to receive(:GetPartition).with(anything, "/dev/sdc1")
.and_return("create" => true)

Expand All @@ -112,16 +120,13 @@
end

it "activate partition if it is on DOS partition table" do
expect(Yast::Storage).to receive(:GetDisk).with(anything, "/dev/sdb1")
.and_return("label" => "dos")
allow(sdb).to receive(:gpt?).and_return(false)
subject.propose

expect(subject.activate?).to eq true
end

it "does not activate partition if it is on GPT" do
expect(Yast::Storage).to receive(:GetDisk).with(anything, "/dev/sdb1")
.and_return("label" => "gpt")
subject.propose

expect(subject.activate?).to eq false
Expand All @@ -143,7 +148,7 @@
end
end

describe "#add_udev_device" do
xdescribe "#add_udev_device" do
it "adds underlayed disk device for lvm disk" do
allow(Bootloader::Stage1Device).to receive(:new).and_call_original
target_map_stub("storage_lvm.yaml")
Expand Down Expand Up @@ -181,7 +186,7 @@
end
end

describe "#can_use_boot?" do
xdescribe "#can_use_boot?" do
before do
allow(subject).to receive(:can_use_boot?).and_call_original
end
Expand All @@ -206,7 +211,7 @@
end
end

describe "#available_locations" do
xdescribe "#available_locations" do
context "on x86_64" do
before do
allow(Yast::Arch).to receive(:architecture).and_return("x86_64")
Expand Down

0 comments on commit dc8ce45

Please sign in to comment.