From 1a61e1e8f523dd2259c6a5c88ee69ac35fc937d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= Date: Wed, 13 Dec 2023 10:19:48 +0100 Subject: [PATCH] Test configuring repositories through command line options --- .../dnf/repo-cmdline-config.feature | 91 +++++++++++++++++++ .../repolist-enablerepo-disablerepo.feature | 34 ------- 2 files changed, 91 insertions(+), 34 deletions(-) create mode 100644 dnf-behave-tests/dnf/repo-cmdline-config.feature delete mode 100644 dnf-behave-tests/dnf/repolist-enablerepo-disablerepo.feature diff --git a/dnf-behave-tests/dnf/repo-cmdline-config.feature b/dnf-behave-tests/dnf/repo-cmdline-config.feature new file mode 100644 index 000000000..15af17c4a --- /dev/null +++ b/dnf-behave-tests/dnf/repo-cmdline-config.feature @@ -0,0 +1,91 @@ +@dnf5 +Feature: Configure repos through cmd line options + + +Scenario: Exit with an error when trying to --enable-repo='*' when there are no repo files + When I execute dnf with args "repo list --enable-repo='*'" + Then the exit code is 2 + And stderr is + """ + No matching repositories for "*". Add "--help" for more information about the arguments. + """ + + +Scenario: Exit with an error when trying to enable missing repo + Given I use repository "simple-base" + When I execute dnf with args "repo list --enable-repo='missing-repo'" + Then the exit code is 2 + And stderr is + """ + No matching repositories for "missing-repo". Add "--help" for more information about the arguments. + """ + + +Scenario: Exit with an error when trying to enable multiple missing repos + Given I use repository "simple-base" + When I execute dnf with args "repo list --enable-repo='missing-repo1' --enable-repo='missing-repo2'" + Then the exit code is 2 + And stderr is + """ + No matching repositories for "missing-repo1, missing-repo2". Add "--help" for more information about the arguments. + """ + + +Scenario: Enabling enabled repo is ok + Given I use repository "simple-base" + When I execute dnf with args "repo list --enable-repo='simple-base'" + Then the exit code is 0 + And stdout is + """ + repo id repo name + simple-base simple-base test repository + """ + + +Scenario: Exit with an error when trying to --disable-repo='*' when there are no repo files + When I execute dnf with args "repo list --disable-repo='*'" + Then the exit code is 2 + And stderr is + """ + No matching repositories for "*". Add "--help" for more information about the arguments. + """ + + +# When there are no repositories the --repo options error report includes "*" because it +# is used internally to disable all repos. This might be confusing to users but the situation +# where there are no repos should be pretty rare. +Scenario: Exit with an error when using --repo but there are no repositories + When I execute dnf with args "repo list --repo='missing-repo'" + Then the exit code is 2 + And stderr is + """ + No matching repositories for "*, missing-repo". Add "--help" for more information about the arguments. + """ + + +Scenario: Exit with an error when --repo specifies invalid repository + Given I use repository "simple-base" + When I execute dnf with args "repo list --repo='missing-repo'" + Then the exit code is 2 + And stderr is + """ + No matching repositories for "missing-repo". Add "--help" for more information about the arguments. + """ + + +Scenario: Exit with an error when --setop specifies invalid repository + When I execute dnf with args "repo list --setopt=missing-repo.best=true" + Then the exit code is 2 + And stderr is + """ + No matching repositories for "missing-repo". Add "--help" for more information about the arguments. + """ + + +Scenario: Exit with an error when trying --setop for all repos but there are none + When I execute dnf with args "repo list --setopt=*.best=true" + Then the exit code is 2 + And stderr is + """ + No matching repositories for "*". Add "--help" for more information about the arguments. + """ diff --git a/dnf-behave-tests/dnf/repolist-enablerepo-disablerepo.feature b/dnf-behave-tests/dnf/repolist-enablerepo-disablerepo.feature deleted file mode 100644 index 58491333f..000000000 --- a/dnf-behave-tests/dnf/repolist-enablerepo-disablerepo.feature +++ /dev/null @@ -1,34 +0,0 @@ -# @dnf5 -# TODO(nsella) different stdout -Feature: Repolist with --enablerepo and --disablerepo - - -# Disabling repositories when there is no match results only in warning, whereas enabling results in error/warning depending on the "strict" option -# --disablerepo strict=true -> warning -# --disablerepo strict=false -> warning -# --enablerepo strict=true -> error -# --enablerepo strict=false -> warning - - -Scenario: List repositories with --enablerepo='*' when there are no repo files - strict - When I execute dnf with args "repolist --enablerepo='*' --setopt=strict=true" - Then the exit code is 1 - And stderr contains "Error: Unknown repo: '*'" - - -Scenario: List repositories with --enablerepo='*' when there are no repo files - not strict - When I execute dnf with args "repolist --enablerepo='*' --setopt=strict=false" - Then the exit code is 0 - And stderr contains "No repositories available" - - -Scenario: List repositories with --disablerepo='*' when there are no repo files - strict - When I execute dnf with args "repolist --disablerepo='*' --setopt=strict=true" - Then the exit code is 0 - And stderr contains "No repositories available" - - -Scenario: List repositories with --disablerepo='*' when there are no repo files - not strict - When I execute dnf with args "repolist --disablerepo='*' --setopt=strict=false" - Then the exit code is 0 - And stderr contains "No repositories available"