Skip to content

Commit

Permalink
Add a couple tests for --store option for transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
kontura authored and pkratoch committed Jul 17, 2024
1 parent db6969c commit 52ee2b0
Showing 1 changed file with 291 additions and 0 deletions.
291 changes: 291 additions & 0 deletions dnf-behave-tests/dnf/transaction-sr/store-option.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,291 @@
@dnf5
Feature: Transaction --store tests

Background:
Given I set working directory to "{context.dnf.tempdir}"
And I use repository "transaction-sr"


Scenario: Store an install transaction
When I execute dnf with args "install top-a-1.0 --store ./transaction"
Then the exit code is 0
And stderr is empty
And file "/{context.dnf.tempdir}/transaction/transaction.json" contents is
"""
{
"rpms":[
{
"nevra":"top-a-1:1.0-1.x86_64",
"action":"Install",
"reason":"User",
"repo_id":"transaction-sr",
"package_path":".\/packages\/top-a-1.0-1.x86_64.rpm"
},
{
"nevra":"mid-a1-1.0-1.x86_64",
"action":"Install",
"reason":"Dependency",
"repo_id":"transaction-sr",
"package_path":".\/packages\/mid-a1-1.0-1.x86_64.rpm"
},
{
"nevra":"bottom-a2-1.0-1.x86_64",
"action":"Install",
"reason":"Dependency",
"repo_id":"transaction-sr",
"package_path":".\/packages\/bottom-a2-1.0-1.x86_64.rpm"
},
{
"nevra":"mid-a2-1.0-1.x86_64",
"action":"Install",
"reason":"Weak Dependency",
"repo_id":"transaction-sr",
"package_path":".\/packages\/mid-a2-1.0-1.x86_64.rpm"
},
{
"nevra":"bottom-a3-1.0-1.x86_64",
"action":"Install",
"reason":"Dependency",
"repo_id":"transaction-sr",
"package_path":".\/packages\/bottom-a3-1.0-1.x86_64.rpm"
}
],
"version":"1.0"
}
"""
When I execute "ls {context.dnf.tempdir}/transaction/"
Then stdout is
"""
packages
transaction.json
"""
When I execute "ls {context.dnf.tempdir}/transaction/packages"
Then stdout is
"""
bottom-a2-1.0-1.x86_64.rpm
bottom-a3-1.0-1.x86_64.rpm
mid-a1-1.0-1.x86_64.rpm
mid-a2-1.0-1.x86_64.rpm
top-a-1.0-1.x86_64.rpm
"""


Scenario: Store a remove transaction
Given I successfully execute dnf with args "install top-a-1.0"
When I execute dnf with args "remove top-a --store ./transaction"
Then the exit code is 0
And file "/{context.dnf.tempdir}/transaction/transaction.json" contents is
"""
{
"rpms":[
{
"nevra":"bottom-a2-1.0-1.x86_64",
"action":"Remove",
"reason":"Clean",
"repo_id":"@System"
},
{
"nevra":"bottom-a3-1.0-1.x86_64",
"action":"Remove",
"reason":"Clean",
"repo_id":"@System"
},
{
"nevra":"mid-a1-1.0-1.x86_64",
"action":"Remove",
"reason":"Clean",
"repo_id":"@System"
},
{
"nevra":"mid-a2-1.0-1.x86_64",
"action":"Remove",
"reason":"Clean",
"repo_id":"@System"
},
{
"nevra":"top-a-1:1.0-1.x86_64",
"action":"Remove",
"reason":"User",
"repo_id":"@System"
}
],
"version":"1.0"
}
"""
When I execute "ls {context.dnf.tempdir}/transaction/"
Then stdout is
"""
transaction.json
"""


Scenario: Store a group install transaction
When I execute dnf with args "install @test-group --store ./transaction"
Then the exit code is 0
And file "/{context.dnf.tempdir}/transaction/transaction.json" contents is
"""
{
"rpms":[
{
"nevra":"top-b-1.0-1.x86_64",
"action":"Install",
"reason":"Group",
"repo_id":"transaction-sr",
"package_path":".\/packages\/top-b-1.0-1.x86_64.rpm"
},
{
"nevra":"top-a-1:2.0-1.x86_64",
"action":"Install",
"reason":"Group",
"repo_id":"transaction-sr",
"package_path":".\/packages\/top-a-2.0-1.x86_64.rpm"
},
{
"nevra":"mid-a1-1.0-1.x86_64",
"action":"Install",
"reason":"Dependency",
"repo_id":"transaction-sr",
"package_path":".\/packages\/mid-a1-1.0-1.x86_64.rpm"
},
{
"nevra":"bottom-a1-2.0-1.noarch",
"action":"Install",
"reason":"Dependency",
"repo_id":"transaction-sr",
"package_path":".\/packages\/bottom-a1-2.0-1.noarch.rpm"
},
{
"nevra":"bottom-a2-1.0-1.x86_64",
"action":"Install",
"reason":"Dependency",
"repo_id":"transaction-sr",
"package_path":".\/packages\/bottom-a2-1.0-1.x86_64.rpm"
},
{
"nevra":"mid-a2-2.0-1.x86_64",
"action":"Install",
"reason":"Weak Dependency",
"repo_id":"transaction-sr",
"package_path":".\/packages\/mid-a2-2.0-1.x86_64.rpm"
},
{
"nevra":"bottom-a3-1.0-1.x86_64",
"action":"Install",
"reason":"Dependency",
"repo_id":"transaction-sr",
"package_path":".\/packages\/bottom-a3-1.0-1.x86_64.rpm"
}
],
"groups":[
{
"id":"test-group",
"action":"Install",
"reason":"User",
"group_path":".\/comps\/test-group.xml",
"repo_id":"transaction-sr",
"package_types":"mandatory, default, conditional"
}
],
"version":"1.0"
}
"""
When I execute "ls {context.dnf.tempdir}/transaction/"
Then stdout is
"""
comps
packages
transaction.json
"""
When I execute "ls {context.dnf.tempdir}/transaction/packages"
Then stdout is
"""
bottom-a1-2.0-1.noarch.rpm
bottom-a2-1.0-1.x86_64.rpm
bottom-a3-1.0-1.x86_64.rpm
mid-a1-1.0-1.x86_64.rpm
mid-a2-2.0-1.x86_64.rpm
top-a-2.0-1.x86_64.rpm
top-b-1.0-1.x86_64.rpm
"""
When I execute "ls {context.dnf.tempdir}/transaction/comps"
Then stdout is
"""
test-group.xml
"""


Scenario: Store a group remove transaction
Given I execute dnf with args "install @test-group"
When I execute dnf with args "remove @test-group --store ./transaction"
Then the exit code is 0
And file "/{context.dnf.tempdir}/transaction/transaction.json" contents is
"""
{
"rpms":[
{
"nevra":"bottom-a1-2.0-1.noarch",
"action":"Remove",
"reason":"Clean",
"repo_id":"@System"
},
{
"nevra":"bottom-a2-1.0-1.x86_64",
"action":"Remove",
"reason":"Clean",
"repo_id":"@System"
},
{
"nevra":"bottom-a3-1.0-1.x86_64",
"action":"Remove",
"reason":"Clean",
"repo_id":"@System"
},
{
"nevra":"mid-a1-1.0-1.x86_64",
"action":"Remove",
"reason":"Clean",
"repo_id":"@System"
},
{
"nevra":"mid-a2-2.0-1.x86_64",
"action":"Remove",
"reason":"Clean",
"repo_id":"@System"
},
{
"nevra":"top-a-1:2.0-1.x86_64",
"action":"Remove",
"reason":"Group",
"repo_id":"@System"
},
{
"nevra":"top-b-1.0-1.x86_64",
"action":"Remove",
"reason":"Group",
"repo_id":"@System"
}
],
"groups":[
{
"id":"test-group",
"action":"Remove",
"reason":"User",
"group_path":".\/comps\/test-group.xml",
"repo_id":"@System",
"package_types":""
}
],
"version":"1.0"
}
"""
When I execute "ls {context.dnf.tempdir}/transaction/"
Then stdout is
"""
comps
transaction.json
"""
When I execute "ls {context.dnf.tempdir}/transaction/comps"
Then stdout is
"""
test-group.xml
"""

0 comments on commit 52ee2b0

Please sign in to comment.