Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Feb 1, 2016
1 parent 13c16eb commit 026ae1c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/lib/bootloader/boot_record_backup.rb
@@ -1,7 +1,5 @@
require "yast"

Yast.import "BootStorage"

module Bootloader
# Responsibility of class is to manage backup of MBR, respective PBR of disk,
# respective partition.
Expand Down Expand Up @@ -50,6 +48,7 @@ def write
copy_br(device, logs_path)

# special backup only if device is mbr disk
Yast.import "BootStorage"
return if device != Yast::BootStorage.mbr_disk

copy_br(device, "/boot/backup_mbr")
Expand Down
2 changes: 1 addition & 1 deletion src/modules/BootStorage.rb
Expand Up @@ -20,7 +20,6 @@
require "yast"
require "bootloader/device_map"
require "bootloader/udev_mapping"
require "bootloader/bootloader_factory"

module Yast
class BootStorageClass < Module
Expand Down Expand Up @@ -96,6 +95,7 @@ def mapRealDevicesToMultipath
end

def gpt_boot_disk?
require "bootloader/bootloader_factory"
current_bl = ::Bootloader::BootloaderFactory.current

# efi require gpt disk, so it is always one
Expand Down
14 changes: 3 additions & 11 deletions test/boot_record_backup_test.rb
Expand Up @@ -4,6 +4,8 @@

require "bootloader/boot_record_backup"

Yast.import "BootStorage"

describe Bootloader::BootRecordBackup do
BASH_PATH = Yast::Path.new(".target.bash")
SIZE_PATH = Yast::Path.new(".target.size")
Expand Down Expand Up @@ -39,8 +41,6 @@
before do
allow(Yast::SCR).to receive(:Execute).with(BASH_PATH, /mkdir/)
allow(Yast::SCR).to receive(:Execute).with(BASH_PATH, /bin\/dd/)
allow(Yast::BootCommon).to receive(:mbrDisk).and_return("/dev/non-exist")
allow(Yast::BootCommon).to receive(:ThinkPadMBR).and_return(false)
allow(Yast::SCR).to receive(:Read).with(SIZE_PATH, anything).and_return(0)
end

Expand Down Expand Up @@ -81,18 +81,10 @@
end

it "store backup of device first 512 bytes to /boot/backup_mbr if it is MBR of primary disk" do
allow(Yast::BootCommon).to receive(:mbrDisk).and_return("/dev/sda")
allow(Yast::BootStorage).to receive(:mbr_disk).and_return("/dev/sda")
expect(Yast::SCR).to receive(:Execute).with(BASH_PATH, /bin\/dd.* of=\/boot\/backup_mbr/)

subject.write
end

it "copy backup of device also to backup_boot_sectors with thinkpadMBR suffix if it is primary disk and contain thinkpad boot code" do
allow(Yast::BootCommon).to receive(:mbrDisk).and_return("/dev/sda")
allow(Yast::BootCommon).to receive(:ThinkPadMBR).and_return(true)

expect(Yast::SCR).to receive(:Execute).with(BASH_PATH, /\Acp.* \/var\/lib\/YaST2\/backup_boot_sectors.*thinkpadMBR/)
subject.write
end
end
end

0 comments on commit 026ae1c

Please sign in to comment.