diff --git a/service/lib/agama/storage/configs/btrfs.rb b/service/lib/agama/storage/configs/btrfs.rb index 21f7f65fe..9ad106e5f 100644 --- a/service/lib/agama/storage/configs/btrfs.rb +++ b/service/lib/agama/storage/configs/btrfs.rb @@ -39,12 +39,6 @@ class Btrfs # @return [String, nil] attr_accessor :default_subvolume - # Constructor - def initialize - @snapshots = false - @read_only = false - end - # @return [Boolean] def snapshots? !!snapshots diff --git a/service/test/agama/storage/config_solver_test.rb b/service/test/agama/storage/config_solver_test.rb index 4973011e5..0717922f0 100644 --- a/service/test/agama/storage/config_solver_test.rb +++ b/service/test/agama/storage/config_solver_test.rb @@ -46,7 +46,7 @@ "mount_path" => "/", "filesystem" => "btrfs", "size" => { "auto" => true, "min" => "5 GiB", "max" => "10 GiB" }, "btrfs" => { - "snapshots" => true, "default_subvolume" => "@", + "snapshots" => true, "default_subvolume" => "@", "read_only" => true, "subvolumes" => ["home", "opt", "root", "srv"] }, "outline" => { @@ -188,12 +188,42 @@ expect(filesystem.type.fs_type).to eq(Y2Storage::Filesystems::Type::BTRFS) expect(filesystem.type.btrfs).to be_a(Agama::Storage::Configs::Btrfs) expect(filesystem.type.btrfs.snapshots?).to eq(true) - expect(filesystem.type.btrfs.read_only?).to eq(false) + expect(filesystem.type.btrfs.read_only?).to eq(true) expect(filesystem.type.btrfs.default_subvolume).to eq("@") expect(filesystem.type.btrfs.subvolumes).to all(be_a(Y2Storage::SubvolSpecification)) end end + context "if a config does not specify all the btrfs properties" do + let(:config_json) do + { + drives: [ + { + filesystem: { + path: "/", + type: { + btrfs: { + snapshots: false + } + } + } + } + ] + } + end + + it "completes the btrfs config according to the product info" do + subject.solve(config) + + drive = config.drives.first + btrfs = drive.filesystem.type.btrfs + expect(btrfs.snapshots?).to eq(false) + expect(btrfs.read_only?).to eq(true) + expect(btrfs.default_subvolume).to eq("@") + expect(btrfs.subvolumes).to all(be_a(Y2Storage::SubvolSpecification)) + end + end + partition_proc = proc { |c| c.drives.first.partitions.first } context "if a config does not specify size" do