Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for pre-transaction-actions plugin #1432

Closed
Closed
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
124 changes: 124 additions & 0 deletions dnf-behave-tests/dnf/plugins-core/pre-transaction-actions.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
Feature: Tests for pre-transaction-actions plugin


Background:
Given I enable plugin "pre-transaction-actions"
And I configure dnf with
| key | value |
| pluginconfpath | {context.dnf.installroot}/etc/dnf/plugins |
And I create and substitute file "/etc/dnf/plugins/pre-transaction-actions.conf" with
"""
[main]
enabled = 1
actiondir = {context.dnf.installroot}/etc/dnf/plugins/pre-transaction-actions.d/
"""
And I use repository "dnf-ci-fedora"


Scenario: Variables in action files are substituted
Given I create and substitute file "/etc/dnf/plugins/pre-transaction-actions.d/test.action" with
"""
*:any:echo '${{state}} ${{name}}-${{epoch}}:${{ver}}-${{rel}}.${{arch}} repo ${{repoid}}' >> {context.dnf.installroot}/trans.log
"""
When I execute dnf with args "-v install setup"
Then the exit code is 0
And Transaction is following
| Action | Package |
| install | setup-0:2.12.1-1.fc29.noarch |
And file "/trans.log" contents is
"""
install setup-0:2.12.1-1.fc29.noarch repo dnf-ci-fedora
"""


Scenario Outline: I can filter on package or file: "<filter>"
Given I create and substitute file "/etc/dnf/plugins/pre-transaction-actions.d/test.action" with
"""
<filter>:any:echo '${{state}} ${{name}}-${{epoch}}:${{ver}}-${{rel}}.${{arch}} repo ${{repoid}}' >> {context.dnf.installroot}/trans.log
"""
When I execute dnf with args "install glibc"
Then the exit code is 0
And Transaction is following
| Action | Package |
| install | glibc-0:2.28-9.fc29.x86_64 |
| install-dep | setup-0:2.12.1-1.fc29.noarch |
| install-dep | glibc-all-langpacks-0:2.28-9.fc29.x86_64 |
| install-dep | glibc-common-0:2.28-9.fc29.x86_64 |
| install-dep | filesystem-0:3.9-2.fc29.x86_64 |
| install-dep | basesystem-0:11-6.fc29.noarch |
And file "/trans.log" contents is
"""
install glibc-0:2.28-9.fc29.x86_64 repo dnf-ci-fedora
"""

Examples:
| filter |
| /etc/ld.so.conf |
| /etc/ld*conf |
| glibc |
| g*c |


Scenario Outline: I can filter on transaction state
Given I create and substitute file "/etc/dnf/plugins/pre-transaction-actions.d/test.action" with
"""
*:<state>:echo '${{state}} ${{name}}' >> {context.dnf.installroot}/trans.log
"""
And I create file "/trans.log" with
"""
"""
When I execute dnf with args "install setup"
Then the exit code is 0
And file "/trans.log" contents is
"""
<output>
"""

Examples:
| state | output |
| any | install setup |
| in | install setup |
| out | |


Scenario: Do not traceback when reason change is in transaction
Given I create and substitute file "/etc/dnf/plugins/pre-transaction-actions.d/test.action" with
"""
*:any:echo '${{state}} ${{name}}-${{epoch}}:${{ver}}-${{rel}}.${{arch}} repo ${{repoid}}' > {context.dnf.installroot}/trans.log
"""
And I use repository "installonly"
And I configure dnf with
| key | value |
| installonlypkgs | installonlyA |
| installonly_limit | 2 |
When I execute dnf with args "-v install installonlyA-1.0"
Then the exit code is 0
And Transaction is following
| Action | Package |
| install | installonlyA-1.0-1.x86_64 |
And stderr does not contain "Traceback"
And file "/trans.log" contents is
"""
install installonlyA-0:1.0-1.x86_64 repo installonly
"""
When I execute dnf with args "-v install installonlyA-2.0"
Then the exit code is 0
And Transaction is following
| Action | Package |
| install | installonlyA-2.0-1.x86_64 |
And stderr does not contain "Traceback"
And file "/trans.log" contents is
"""
install installonlyA-0:2.0-1.x86_64 repo installonly
"""
When I execute dnf with args "-v install installonlyA-2.2"
Then the exit code is 0
And Transaction is following
| Action | Package |
| install | installonlyA-2.2-1.x86_64 |
| remove | installonlyA-1.0-1.x86_64 |
And stderr does not contain "Traceback"
And file "/trans.log" contents is
"""
install installonlyA-0:2.2-1.x86_64 repo installonly
"""
Loading