Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Mar 15, 2018
1 parent 524f5b2 commit 7174a0f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/lib/y2storage/proposal/autoinst_devices_planner.rb
Expand Up @@ -90,22 +90,23 @@ def planned_devices(drives_map)
# @return [Array<Planned::Partition>] List of planned partitions
def planned_for_disk(disk, drive)
result = []
drive.partitions.each_with_index do |partition_section|
drive.partitions.each_with_index do |section|
# TODO: fix Planned::Partition.initialize
partition = Y2Storage::Planned::Partition.new(nil, nil)

next unless assign_size_to_partition(disk, partition, partition_section)
next unless assign_size_to_partition(disk, partition, section)

# TODO: partition.bootable is not in the AutoYaST profile. Check if
# there's some logic to set it in the old code.

partition.disk = disk.name
partition.partition_id = partition_section.id_for_partition
partition.lvm_volume_group_name = partition_section.lvm_group
partition.raid_name = partition_section.raid_name
partition.partition_id = section.id_for_partition
partition.lvm_volume_group_name = section.lvm_group
partition.raid_name = section.raid_name
partition.primary = section.partition_type == "primary" if section.partition_type

device_config(partition, partition_section, drive)
add_partition_reuse(partition, partition_section) if partition_section.create == false
device_config(partition, section, drive)
add_partition_reuse(partition, section) if section.create == false

result << partition
end
Expand Down
36 changes: 36 additions & 0 deletions test/y2storage/proposal/autoinst_devices_planner_test.rb
Expand Up @@ -133,6 +133,42 @@
end
end

context "specifying partition type" do
let(:root_spec) do
{ "mount" => "/", "size" => size, "partition_type" => "primary" }
end

context "when partition_type is set to 'primary'" do
let(:root_spec) { { "mount" => "/", "size" => "max", "partition_type" => "primary" } }

it "sets the planned device as 'primary'" do
devices = planner.planned_devices(drives_map)
root = devices.find { |d| d.mount_point == "/" }
expect(root.primary).to eq(true)
end
end

context "when parition_type is set to other value" do
let(:root_spec) { { "mount" => "/", "size" => "max", "partition_type" => "logical" } }

it "sets planned device as not 'primary'" do
devices = planner.planned_devices(drives_map)
root = devices.find { |d| d.mount_point == "/" }
expect(root.primary).to eq(false)
end
end

context "when parition_type is not set" do
let(:root_spec) { { "mount" => "/", "size" => "max" } }

it "does not set 'primary'" do
devices = planner.planned_devices(drives_map)
root = devices.find { |d| d.mount_point == "/" }
expect(root.primary).to eq(false)
end
end
end

context "specifying size" do
using Y2Storage::Refinements::SizeCasts

Expand Down

0 comments on commit 7174a0f

Please sign in to comment.