-
-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use new types Systemd::Unit::Amount, Systemd::Unit::Percent and Syste…
…md::Unit::AmountOrPerecnt
- Loading branch information
1 parent
fca90f2
commit 12d3822
Showing
9 changed files
with
115 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Systemd::Unit::Amount' do | ||
it { is_expected.to allow_value(100) } | ||
it { is_expected.to allow_value('200') } | ||
it { is_expected.to allow_value('8G') } | ||
it { is_expected.to allow_value('1T') } | ||
it { is_expected.to allow_value('infinity') } | ||
|
||
it { is_expected.not_to allow_value('1P') } | ||
it { is_expected.not_to allow_value('10%') } | ||
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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Systemd::Unit::AmountOrPercent' do | ||
it { is_expected.to allow_value(100) } | ||
it { is_expected.to allow_value('200') } | ||
it { is_expected.to allow_value('8G') } | ||
it { is_expected.to allow_value('1T') } | ||
it { is_expected.to allow_value('infinity') } | ||
it { is_expected.to allow_value('10%') } | ||
|
||
it { is_expected.not_to allow_value('1P') } | ||
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,11 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'Systemd::Unit::Percent' do | ||
it { is_expected.to allow_value('1%') } | ||
it { is_expected.to allow_value('100%') } | ||
|
||
it { is_expected.not_to allow_value(1) } | ||
it { is_expected.not_to allow_value('105%') } | ||
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
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 @@ | ||
# @summary Systemd definition of amount, often bytes or united bytes | ||
# @see https://www.freedesktop.org/software/systemd/man/systemd.service.html | ||
# @see https://www.freedesktop.org/software/systemd/man/systemd.slice.html | ||
# | ||
type Systemd::Unit::Amount = Variant[Integer[0],Pattern['\A(infinity|\d+(K|M|G|T)?(:\d+(K|M|G|T)?)?)\z']] |
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 @@ | ||
# @summary Systemd definition of amount, often bytes or united bytes | ||
# @see https://www.freedesktop.org/software/systemd/man/systemd.service.html | ||
# @see https://www.freedesktop.org/software/systemd/man/systemd.slice.html | ||
# | ||
type Systemd::Unit::AmountOrPercent = Variant[Systemd::Unit::Amount,Systemd::Unit::Percent] |
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 @@ | ||
# @summary Systemd definition of a percentage | ||
# @see https://www.freedesktop.org/software/systemd/man/systemd.service.html | ||
# @see https://www.freedesktop.org/software/systemd/man/systemd.slice.html | ||
# | ||
type Systemd::Unit::Percent = Pattern['\A([0-9][0-9]?|100)%\z'] |
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