-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #235 from yast/set-default-subvolume-name
Set default subvolume name
- Loading branch information
Showing
14 changed files
with
643 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/env rspec | ||
|
||
require_relative "spec_helper" | ||
|
||
Yast.import "FileSystems" | ||
Yast.import "Storage" | ||
|
||
describe Yast::FileSystems do | ||
subject { Yast::FileSystems } | ||
|
||
def btrfs_list_fixture(name) | ||
fixture_name = "btrfs_list_#{name}.out" | ||
File.read(File.join(FIXTURES_PATH, fixture_name)) | ||
end | ||
|
||
let(:default_subvol) { "@" } | ||
let(:libstorage) do | ||
double("libstorage", getDefaultSubvolName: default_subvol, setDefaultSubvolName: default_subvol) | ||
end | ||
|
||
before do | ||
subject.InitSlib(libstorage) | ||
end | ||
|
||
describe "#default_subvol_from_target" do | ||
before do | ||
allow(Yast::Storage).to receive(:GetTargetMap).and_return(target_map) | ||
allow(Yast::ProductFeatures).to receive(:GetStringFeature) | ||
.with("partitioning", "btrfs_default_subvolume").and_return(default_subvol) | ||
end | ||
|
||
context "when root partition uses the default subvolume name (@)" do | ||
let(:target_map) { YAML.load_file(File.join(FIXTURES_PATH, "subvolumes.yml")) } | ||
|
||
before do | ||
allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/", anything) | ||
.and_return(btrfs_list_fixture("root")) | ||
allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/srv", anything) | ||
.and_return(btrfs_list_fixture("root_no_at")) | ||
end | ||
|
||
it "returns the default subvolume name" do | ||
expect(subject.default_subvol_from_target).to eq(default_subvol) | ||
end | ||
end | ||
|
||
context "when root partitions does not use btrfs" do | ||
let(:target_map) { YAML.load_file(File.join(FIXTURES_PATH, "subvolumes-no-root.yml")) } | ||
|
||
before do | ||
allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/", anything) | ||
.and_return(btrfs_list_fixture("root_no_at")) | ||
end | ||
|
||
context "but all btrfs partitions uses the same subvolume name" do | ||
before do | ||
allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/srv", anything) | ||
.and_return(btrfs_list_fixture("srv_no_at")) | ||
allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/data", anything) | ||
.and_return(btrfs_list_fixture("data_no_at")) | ||
end | ||
|
||
it "returns the used name ('' in this case)" do | ||
expect(subject.default_subvol_from_target).to eq("") | ||
end | ||
end | ||
|
||
context "and btrfs partitions uses different subvolume names" do | ||
before do | ||
allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/srv", anything) | ||
.and_return(btrfs_list_fixture("srv")) | ||
allow(Yast::Execute).to receive(:on_target).with("btrfs", "subvol", "list", "/data", anything) | ||
.and_return(btrfs_list_fixture("data_no_at")) | ||
end | ||
|
||
it "returns the distribution default" do | ||
expect(subject.default_subvol_from_target).to eq(default_subvol) | ||
end | ||
end | ||
end | ||
end | ||
|
||
describe "#read_default_subvol_from_target" do | ||
it "sets the default_subvol using the value from target" do | ||
subject.default_subvol = "" | ||
expect(subject).to receive(:default_subvol_from_target).and_return("@") | ||
expect { subject.read_default_subvol_from_target }.to change { subject.default_subvol } | ||
.from("").to("@") | ||
end | ||
end | ||
|
||
describe "#default_subvol=" do | ||
it "sets the default_subvol if a valid value is given" do | ||
expect(libstorage).to receive(:setDefaultSubvolName).with("@") | ||
subject.default_subvol = "@" | ||
end | ||
|
||
it "refuses to set default_subvol if an invalid value is given" do | ||
expect(libstorage).to_not receive(:setDefaultSubvolName) | ||
subject.default_subvol = "UNDEFINED" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
ID 257 gen 16 top level 5 path shared | ||
ID 258 gen 16 top level 5 path private | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
ID 257 gen 34 top level 5 path @ | ||
ID 258 gen 51 top level 257 path @/.snapshots | ||
ID 259 gen 88 top level 258 path @/.snapshots/1/snapshot | ||
ID 260 gen 44 top level 257 path @/boot/grub2/i386-pc | ||
ID 261 gen 15 top level 257 path @/boot/grub2/x86_64-efi | ||
ID 262 gen 44 top level 257 path @/home | ||
ID 263 gen 51 top level 257 path @/opt | ||
ID 264 gen 50 top level 257 path @/srv | ||
ID 265 gen 88 top level 257 path @/tmp | ||
ID 266 gen 64 top level 257 path @/usr/local | ||
ID 267 gen 38 top level 257 path @/var/crash | ||
ID 268 gen 22 top level 257 path @/var/lib/mailman | ||
ID 269 gen 88 top level 257 path @/var/lib/named | ||
ID 270 gen 24 top level 257 path @/var/lib/pgsql | ||
ID 271 gen 88 top level 257 path @/var/log | ||
ID 272 gen 38 top level 257 path @/var/opt | ||
ID 273 gen 84 top level 257 path @/var/spool | ||
ID 274 gen 51 top level 257 path @/var/tmp | ||
ID 275 gen 30 top level 257 path @/mysubvol | ||
ID 276 gen 47 top level 275 path @/mysubvol/mysubsubvol | ||
ID 277 gen 32 top level 257 path @/myothersubvol | ||
ID 278 gen 47 top level 277 path @/myothersubvol/myothersubsubvol | ||
ID 279 gen 33 top level 257 path @/nocow | ||
ID 280 gen 35 top level 257 path @/myvol | ||
ID 282 gen 40 top level 259 path var/lib/machines | ||
ID 283 gen 48 top level 258 path @/.snapshots/2/snapshot | ||
ID 284 gen 49 top level 258 path @/.snapshots/3/snapshot | ||
ID 285 gen 50 top level 258 path @/.snapshots/4/snapshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
ID 257 gen 48 top level 5 path .snapshots | ||
ID 258 gen 92 top level 257 path .snapshots/1/snapshot | ||
ID 259 gen 41 top level 5 path boot/grub2/i386-pc | ||
ID 260 gen 12 top level 5 path boot/grub2/x86_64-efi | ||
ID 261 gen 41 top level 5 path home | ||
ID 262 gen 49 top level 5 path opt | ||
ID 263 gen 47 top level 5 path srv | ||
ID 264 gen 91 top level 5 path tmp | ||
ID 265 gen 61 top level 5 path usr/local | ||
ID 266 gen 35 top level 5 path var/crash | ||
ID 267 gen 19 top level 5 path var/lib/mailman | ||
ID 268 gen 89 top level 5 path var/lib/named | ||
ID 269 gen 21 top level 5 path var/lib/pgsql | ||
ID 270 gen 90 top level 5 path var/log | ||
ID 271 gen 35 top level 5 path var/opt | ||
ID 272 gen 91 top level 5 path var/spool | ||
ID 273 gen 48 top level 5 path var/tmp | ||
ID 274 gen 27 top level 5 path mysubvol | ||
ID 275 gen 44 top level 274 path mysubvol/mysubsubvol | ||
ID 276 gen 29 top level 5 path @/myothersubvol | ||
ID 277 gen 44 top level 276 path @/myothersubvol/myothersubsubvol | ||
ID 278 gen 30 top level 5 path nocow | ||
ID 279 gen 32 top level 5 path myvol | ||
ID 281 gen 37 top level 258 path var/lib/machines | ||
ID 282 gen 45 top level 257 path .snapshots/2/snapshot | ||
ID 283 gen 46 top level 257 path .snapshots/3/snapshot | ||
ID 284 gen 47 top level 257 path .snapshots/4/snapshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ID 257 gen 16 top level 5 path @ | ||
ID 258 gen 16 top level 257 path www | ||
ID 259 gen 16 top level 257 path mirror | ||
ID 260 gen 16 top level 257 path ftp | ||
ID 261 gen 16 top level 257 path tftpboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
ID 257 gen 16 top level 5 path www | ||
ID 258 gen 16 top level 5 path mirror | ||
ID 259 gen 16 top level 5 path ftp | ||
ID 260 gen 16 top level 5 path tftpboot | ||
|
Oops, something went wrong.