Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antoine Lambert
swh-core
Commits
5644f9cd
Verified
Commit
5644f9cd
authored
2 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
Add missing coverage on `swh db version` cli
Discovered when working on [1]. Related to T4228 [1] D7949
parent
47d9e8e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/core/db/tests/test_cli.py
+23
-0
23 additions, 0 deletions
swh/core/db/tests/test_cli.py
with
23 additions
and
0 deletions
swh/core/db/tests/test_cli.py
+
23
−
0
View file @
5644f9cd
...
...
@@ -334,3 +334,26 @@ def test_cli_swh_db_upgrade_new_api(cli_runner, postgresql, datadir, mocker, tmp
in
result
.
output
)
assert
swh_db_module
(
conninfo
)
==
module_name
def
test_cli_swh_db_version
(
swh_db_cli
,
mock_import_swhmodule
,
postgresql
):
module_name
=
"
test.cli
"
cli_runner
,
db_params
=
swh_db_cli
conninfo
=
craft_conninfo
(
postgresql
,
"
test-db-version
"
)
# This creates the db and installs the necessary admin extensions
result
=
cli_runner
.
invoke
(
swhdb
,
[
"
create
"
,
module_name
,
"
--dbname
"
,
conninfo
])
assert
result
.
exit_code
==
0
,
f
"
Unexpected output:
{
result
.
output
}
"
# This initializes the schema and data
result
=
cli_runner
.
invoke
(
swhdb
,
[
"
init
"
,
module_name
,
"
--dbname
"
,
conninfo
])
actual_db_version
=
swh_db_version
(
conninfo
)
with
BaseDb
.
connect
(
conninfo
).
cursor
()
as
cur
:
cur
.
execute
(
"
select version from dbversion order by version desc limit 1
"
)
expected_version
=
cur
.
fetchone
()[
0
]
assert
actual_db_version
==
expected_version
assert
result
.
exit_code
==
0
,
f
"
Unexpected output:
{
result
.
output
}
"
assert
f
"
initialized at version
{
expected_version
}
"
in
result
.
output
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment