Skip to content

Commit

Permalink
dnf5 config-manager: Add tests for warning messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jrohel authored and pkratoch committed Mar 8, 2024
1 parent 724d7ad commit ba3fb59
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 3 deletions.
113 changes: 111 additions & 2 deletions dnf-behave-tests/dnf/plugins-core/config-manager-opts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,28 @@ Scenario: unset/remove an main option
"""


Scenario: unset/remove an main option, trying to unset an not set option is OK
Scenario: unset/remove unsupported main option is OK, but a warning is written
Given I create file "/etc/dnf/dnf.conf" with
"""
[main]
best=True
unsupported=1
skip_unavailable=True
"""
When I execute dnf with args "config-manager unsetopt best unsupported"
Then the exit code is 0
And file "/etc/dnf/dnf.conf" contents is
"""
[main]
skip_unavailable=True
"""
And stderr is
"""
config-manager: Request to remove unsupported main option: unsupported
"""


Scenario: unset/remove an main option, trying to unset an not set option is OK, but a warning is written
Given I create file "/etc/dnf/dnf.conf" with
"""
[main]
Expand All @@ -144,6 +165,20 @@ Scenario: unset/remove an main option, trying to unset an not set option is OK
[main]
skip_unavailable=True
"""
And stderr is
"""
config-manager: Request to remove main option but it is not present in the config file: installroot
"""


Scenario: trying to unset an not set main option (config file is not found) is OK, but a warning is written
Given I delete file "/etc/dnf/dnf.conf"
When I execute dnf with args "config-manager unsetopt best"
Then the exit code is 0
And stderr is
"""
config-manager: Request to remove main option but config file not found: {context.dnf.installroot}/etc/dnf/dnf.conf
"""


Scenario: repository configuration overrides - new option to "repo1"
Expand Down Expand Up @@ -321,7 +356,68 @@ Scenario: repository configuration overrides - unset/remove option, globs in rep
"""


Scenario: repository configuration overrides - unset/remove option, trying to unset an not set option is OK
Scenario: repository configuration overrides - unset/remove unsupported option is OK, but a warning is written
Given I create file "/etc/dnf/repos.override.d/99-config_manager.repo" with
"""
[repo1]
enabled=0
unsupported=1
priority=40
skip_if_unavailable=1
[repo2]
enabled=1
priority=50
skip_if_unavailable=0
"""
When I execute dnf with args "config-manager unsetopt repo1.unsupported repo1.priority"
Then the exit code is 0
And file "/etc/dnf/repos.override.d/99-config_manager.repo" contents is
"""
[repo1]
enabled=0
skip_if_unavailable=1
[repo2]
enabled=1
priority=50
skip_if_unavailable=0
"""
And stderr is
"""
config-manager: Request to remove unsupported repository option: repo1.unsupported
"""


Scenario: repository configuration overrides - unset/remove option, repoid not in overrides is OK, but a warning is written
Given I create file "/etc/dnf/repos.override.d/99-config_manager.repo" with
"""
[repo1]
enabled=0
priority=40
skip_if_unavailable=1
[repo2]
enabled=1
priority=50
skip_if_unavailable=0
"""
When I execute dnf with args "config-manager unsetopt test_repo.priority repo1.priority"
Then the exit code is 0
And file "/etc/dnf/repos.override.d/99-config_manager.repo" contents is
"""
[repo1]
enabled=0
skip_if_unavailable=1
[repo2]
enabled=1
priority=50
skip_if_unavailable=0
"""
And stderr is
"""
config-manager: Request to remove repository option but repoid is not present in the overrides: test_repo
"""


Scenario: repository configuration overrides - unset/remove option, trying to unset an not set option is OK, but a warning is written
Given I create file "/etc/dnf/repos.override.d/99-config_manager.repo" with
"""
[repo1]
Expand All @@ -345,6 +441,19 @@ Scenario: repository configuration overrides - unset/remove option, trying to un
priority=50
skip_if_unavailable=0
"""
And stderr is
"""
config-manager: Request to remove repository option but it is not present in the overrides: repo1.cost
"""


Scenario: repository configuration overrides - unset/remove option, no file with overrides found is OK, but a warning is written
When I execute dnf with args "config-manager unsetopt repo1.cost"
Then the exit code is 0
And stderr is
"""
config-manager: Request to remove repository option but file with overrides not found: {context.dnf.installroot}/etc/dnf/repos.override.d/99-config_manager.repo
"""


Scenario: repository configuration overrides - unset/remove option, empty section is removed
Expand Down
15 changes: 14 additions & 1 deletion dnf-behave-tests/dnf/plugins-core/config-manager-vars.feature
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Scenario: unset/remove an existing variable
"""


Scenario: unset/remove an existing variable, removing non-existent variable is OK
Scenario: unset/remove an existing variable, removing non-existent variable is OK, but a warning is written
Given I create file "/etc/dnf/vars/mvar1" with
"""
orig_value1
Expand All @@ -119,3 +119,16 @@ Scenario: unset/remove an existing variable, removing non-existent variable is O
"""
orig_value2
"""
And stderr is
"""
config-manager: Request to remove variable but it is not present in the vars directory: nonexistvar
"""


Scenario: removing non-existent variable (directory with variables not found) is OK, but a warning is written
When I execute dnf with args "config-manager unsetvar nonexistvar"
Then the exit code is 0
And stderr is
"""
config-manager: Request to remove variable but vars directory was not found: {context.dnf.installroot}/etc/dnf/vars
"""

0 comments on commit ba3fb59

Please sign in to comment.