Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,25 @@ def convert
# @see Base#conversions
def conversions
{
min: config.min&.to_i,
min: convert_min_size,
max: convert_max_size
}
end

# @return [Integer, nil]
# @return [String, Integer]
def convert_min_size
return "current" unless config.min

config.min.to_i
end

# @return [String, Integer, nil]
def convert_max_size
max = config.max
return if max.nil? || max.unlimited?
return "current" unless config.max

return if config.max.unlimited?

max.to_i
config.max.to_i
end
end
end
Expand Down
5 changes: 5 additions & 0 deletions service/package/rubygem-agama-yast.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Mon Sep 15 13:50:54 UTC 2025 - José Iván López González <jlopez@suse.com>

- Fix JSON conversion for not configured sizes (bsc#1249591).

-------------------------------------------------------------------
Fri Sep 12 08:14:28 UTC 2025 - Ladislav Slezák <lslezak@suse.com>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,29 @@
)
end

context "if min size is not configured" do
let(:size) do
Comment thread
ancorgs marked this conversation as resolved.
{
min: "1 GiB",
max: "10 GiB"
}
end

before do
config.size.min = nil
end

it "generates the expected JSON" do
config_json = subject.convert
expect(config_json[:size]).to eq(
{
min: "current",
max: 10.GiB.to_i
}
)
end
end

context "if max size is unlimited" do
let(:size) do
{
Expand All @@ -386,6 +409,28 @@
end
end

context "if max size is not configured" do
let(:size) do
{
min: "1 GiB"
}
end

before do
config.size.max = nil
end
Comment thread
ancorgs marked this conversation as resolved.

it "generates the expected JSON" do
config_json = subject.convert
expect(config_json[:size]).to eq(
{
min: 1.GiB.to_i,
max: "current"
}
)
end
end

context "if size is default" do
before do
size_config = config.size
Expand Down