Skip to content

Commit

Permalink
Merge pull request #499 from yast/test_fix
Browse files Browse the repository at this point in the history
do not use alias in mocking
  • Loading branch information
jreidinger committed May 2, 2018
2 parents 479ad23 + 9de0de8 commit aaac72e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
6 changes: 6 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed May 2 10:35:56 UTC 2018 - jreidinger@suse.com

- Fix test failure on s390 (no functionality change)(bsc#1091631)
- 4.0.28

-------------------------------------------------------------------
Tue Apr 24 14:36:12 UTC 2018 - jreidinger@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 4.0.27
Version: 4.0.28
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
4 changes: 3 additions & 1 deletion test/data/trivial.yaml
Expand Up @@ -10,7 +10,7 @@
name: /dev/sda1
id: bios_boot
file_system: vfat
uuid: 3de29985-8cc6-4c9d-8562-2ede26b0c5b6
uuid: 3de29985-8cc6-4c9d-8562-2ede26b0c5b7

- partition:
size: 1002 MiB
Expand All @@ -25,3 +25,5 @@
name: /dev/sda3
file_system: btrfs
mount_point: "/"
uuid: 3de29985-8cc6-4c9d-8562-2ede26b0c5b6
label: DATA
40 changes: 15 additions & 25 deletions test/udev_mapping_test.rb
Expand Up @@ -32,7 +32,7 @@
end

it "return kernel device name for udev mapped name" do
expect(subject.to_kernel_device("/dev/disk/by-uuid/3de29985-8cc6-4c9d-8562-2ede26b0c5b6")).to eq "/dev/sda1"
expect(subject.to_kernel_device("/dev/disk/by-uuid/3de29985-8cc6-4c9d-8562-2ede26b0c5b6")).to eq "/dev/sda3"
end

it "raise exception if udev link is not known" do
Expand All @@ -48,57 +48,47 @@
allow(Y2Storage::BlkDevice).to receive(:find_by_name).and_return(device)
end

it "returns udev link in same format as used to its mounting if defined" do
allow(device).to receive(:blk_filesystem).and_return(
double(
mount_by: Y2Storage::Filesystems::MountByType.new(:uuid),
uuid: "3de29985-8cc6-4c9d-8562-2ede26b0c5b6"
)
)
it "returns udev link in same format as used to its mounting" do
device.filesystem.mount_point.mount_by = Y2Storage::Filesystems::MountByType.new(:uuid)

expect(subject.to_mountby_device(device.name)).to eq "/dev/disk/by-uuid/3de29985-8cc6-4c9d-8562-2ede26b0c5b6"
end

it "returns udev link by label if defined" do
allow(device).to receive(:blk_filesystem).and_return(
double(
mount_by: Y2Storage::Filesystems::MountByType.new(:uuid),
uuid: nil,
label: "DATA"
)
)
device.filesystem.remove_mount_point

expect(subject.to_mountby_device(device.name)).to eq "/dev/disk/by-label/DATA"
end

it "returns udev link by uuid if defined" do
allow(device).to receive(:blk_filesystem).and_return(
double(
mount_by: Y2Storage::Filesystems::MountByType.new(:label),
uuid: "3de29985-8cc6-4c9d-8562-2ede26b0c5b6",
label: ""
)
)
device.filesystem.remove_mount_point
allow(device).to receive(:udev_full_label).and_return(nil)

expect(subject.to_mountby_device(device.name)).to eq "/dev/disk/by-uuid/3de29985-8cc6-4c9d-8562-2ede26b0c5b6"
end

it "returns first udev link by id if defined" do
allow(device).to receive(:blk_filesystem).and_return(nil)
device.filesystem.remove_mount_point
allow(device).to receive(:udev_full_label).and_return(nil)
allow(device).to receive(:udev_full_uuid).and_return(nil)
allow(device).to receive(:udev_ids).and_return(["abc", "cde"])

expect(subject.to_mountby_device(device.name)).to eq "/dev/disk/by-id/abc"
end

it "returns first udev link by path if defined" do
allow(device).to receive(:blk_filesystem).and_return(nil)
device.filesystem.remove_mount_point
allow(device).to receive(:udev_full_label).and_return(nil)
allow(device).to receive(:udev_full_uuid).and_return(nil)
allow(device).to receive(:udev_paths).and_return(["abc", "cde"])

expect(subject.to_mountby_device(device.name)).to eq "/dev/disk/by-path/abc"
end

it "returns kernel name as last fallback" do
allow(device).to receive(:blk_filesystem).and_return(nil)
device.filesystem.remove_mount_point
allow(device).to receive(:udev_full_label).and_return(nil)
allow(device).to receive(:udev_full_uuid).and_return(nil)

expect(subject.to_mountby_device(device.name)).to eq device.name
end
Expand Down

0 comments on commit aaac72e

Please sign in to comment.