Skip to content

Commit

Permalink
add tests and fix founded issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Mar 17, 2015
1 parent 0ea2efa commit 0bf5a13
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/modules/BootStorage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class BootStorageClass < Module
def main
textdomain "bootloader"

Yast.import "BootCommon"
Yast.import "Storage"
Yast.import "StorageDevices"
Yast.import "Arch"
Expand Down Expand Up @@ -419,7 +420,7 @@ def detect_disks
log.info "mountPoints #{mp}"
log.info "mountdata_boot #{mountdata_boot}"

@RootPartitionDevice = mountdata_root.first || ""
@RootPartitionDevice = mountdata_root ? mountdata_root.first || "" : ""
raise "No mountpoint for / !!" if @RootPartitionDevice.empty?

# if /boot changed, re-configure location
Expand Down
55 changes: 55 additions & 0 deletions test/boot_storage_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,59 @@
expect(subject.multipath_mapping["/dev/sda"]).to eq "/dev/mapper/3600508b1001c9a84c91492de27962d57"
end
end

describe ".detect_disks" do
before do
mock_disk_partition
target_map_stub("storage_lvm.rb")

allow(Yast::Storage).to receive(:GetMountPoints).and_return(
"/" => ["/dev/vda1"],
"/boot" => ["/dev/vda2"]
)
end

it "fills RootPartitionDevice variable" do
subject.RootPartitionDevice = nil

subject.detect_disks

expect(subject.RootPartitionDevice).to eq "/dev/vda1"
end

it "fills BootPartitionDevice variable" do
subject.BootPartitionDevice = nil

subject.detect_disks

expect(subject.BootPartitionDevice).to eq "/dev/vda2"
end

it "sets ExtendedPartitionDevice variable to nil if boot is not logical" do
subject.ExtendedPartitionDevice = nil

subject.detect_disks

expect(subject.ExtendedPartitionDevice).to eq nil
end

# need target map with it
it "sets ExtendedPartitionDevice variable to extended partition if boot is logical"

it "raises exception if there is no mount point for root" do
allow(Yast::Storage).to receive(:GetMountPoints).and_return({})

expect{subject.detect_disks}.to raise_error
end

it "sets BootCommon.mbrDisk if not already set" do
Yast::BootCommon.mbrDisk = nil

expect(Yast::BootCommon).to receive(:FindMBRDisk).and_return("/dev/vda")

subject.detect_disks

expect(Yast::BootCommon.mbrDisk).to eq "/dev/vda"
end
end
end

0 comments on commit 0bf5a13

Please sign in to comment.