Skip to content

Commit

Permalink
service: Adapt Filesystem interface
Browse files Browse the repository at this point in the history
  • Loading branch information
joseivanlopez committed Mar 8, 2024
1 parent f94680d commit d2ce25e
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 8 deletions.
19 changes: 14 additions & 5 deletions service/lib/agama/dbus/storage/interfaces/device/filesystem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# find current contact information at www.suse.com.

require "dbus"
require "y2storage/filesystem_label"

module Agama
module DBus
Expand Down Expand Up @@ -51,18 +52,26 @@ def filesystem_type
storage_device.filesystem.type.to_s
end

# Whether the filesystem contains the directory layout of an ESP partition.
# Mount path of the file system.
#
# @return [Boolean]
def filesystem_efi?
storage_device.filesystem.efi?
# @return [String] Empty if not mounted.
def filesystem_mount_path
storage_device.filesystem.mount_path || ""
end

# Label of the file system.
#
# @return [String] Empty if it has no label.
def filesystem_label
Y2Storage::FilesystemLabel.new(storage_device).to_s
end

def self.included(base)
base.class_eval do
dbus_interface FILESYSTEM_INTERFACE do
dbus_reader :filesystem_type, "s", dbus_name: "Type"
dbus_reader :filesystem_efi?, "b", dbus_name: "EFI"
dbus_reader :filesystem_mount_path, "s", dbus_name: "MountPath"
dbus_reader :filesystem_label, "s", dbus_name: "Label"
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# find current contact information at www.suse.com.

require_relative "../../../../../test_helper"
require "y2storage/filesystem_label"

shared_examples "Filesystem interface" do
describe "Filesystem D-Bus interface" do
Expand All @@ -33,9 +34,37 @@
end
end

describe "#filesystem_efi?" do
it "returns whether the file system is an EFI" do
expect(subject.filesystem_efi?).to eq(false)
describe "#filesystem_mount_path" do
context "if the file system is mounted" do
before do
device.filesystem.mount_path = "/test"
end

it "returns the mount path" do
expect(subject.filesystem_mount_path).to eq("/test")
end
end

context "if the file system is not mounted" do
before do
device.filesystem.mount_path = ""
end

it "returns empty string" do
expect(subject.filesystem_mount_path).to eq("")
end
end
end

describe "#filesystem_label" do
before do
allow(Y2Storage::FilesystemLabel).to receive(:new).with(device).and_return(label)
end

let(:label) { instance_double(Y2Storage::FilesystemLabel, to_s: "photos") }

it "returns the label of the file system" do
expect(subject.filesystem_label).to eq("photos")
end
end
end
Expand Down

0 comments on commit d2ce25e

Please sign in to comment.