Skip to content

Commit

Permalink
Do not remove an empty subvolumes list when cloning
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Oct 18, 2017
1 parent d0201f3 commit 555654e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/modules/AutoinstPartition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def parsePartition(part)
newPart["subvolumes"] = part["subvolumes"].reject do |subvolume|
subvolume["path"].start_with?(".snapshots")
end
else
elsif newPart["filesystem"] != :btrfs
newPart = Builtins.remove(newPart, "subvolumes")
end
if !Builtins.isempty(Ops.get_string(part, "used_pool", ""))
Expand Down
50 changes: 50 additions & 0 deletions test/AutoinstPartition_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env rspec

require_relative "test_helper"

Yast.import "AutoinstPartition"

describe "Yast::AutoinstPartition" do
subject { Yast::AutoinstPartition }

describe "#parsePartition" do
let(:filesystem) { :btrfs }
let(:partition) do
{
"filesystem" => filesystem,
"subvolumes" => [
{ "path" => ".snapshots/1" },
{ "path" => "var/lib/machines" }
]
}
end

it "filters out snapper snapshots" do
parsed = subject.parsePartition(partition)

expect(parsed["subvolumes"]).to eq(
[{ "path" => "var/lib/machines" }]
)
end

context "when there are no Btrfs subvolumes" do
let(:partition) { { "subvolumes" => [] } }

it "exports them as an empty array" do
parsed = subject.parsePartition(partition)

expect(parsed["subvolumes"]).to eq([])
end

context "and filesystem is not Btrfs" do
let(:filesystem) { :ext4 }

it "does not export the subvolumes list" do
parsed = subject.parsePartition(partition)

expect(parsed["subvolumes"]).to eq([])
end
end
end
end
end
1 change: 1 addition & 0 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ TESTS = \
AutoinstConfig_tests.rb \
AutoinstFunctions_test.rb \
AutoinstGeneral_test.rb \
AutoinstPartition_test.rb \
AutoinstPartPlan_test.rb \
AutoinstSoftware_test.rb \
profile_test.rb \
Expand Down

0 comments on commit 555654e

Please sign in to comment.