From abe9d90c891fe61b0b0e7d1729dc89ca10b3b2e8 Mon Sep 17 00:00:00 2001 From: Stefan Fercot Date: Tue, 27 Oct 2020 13:34:18 +0100 Subject: [PATCH] Improve info command output when a stanza is specified but missing. Return a path missing error when a stanza is specified for the info command but the stanza does not exist in the repository. Previously [] was returned, which is still the case if no stanza is specified and the repository does not exist. --- doc/xml/release.xml | 11 +++++++++++ src/command/info/info.c | 2 +- test/src/module/command/infoTest.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/doc/xml/release.xml b/doc/xml/release.xml index cb075e08f..7b4ad2549 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -50,6 +50,17 @@ + + + + + + + + +

Improve info command output when a stanza is specified but missing.

+
+ diff --git a/src/command/info/info.c b/src/command/info/info.c index 0addd89a4..0db4be5ea 100644 --- a/src/command/info/info.c +++ b/src/command/info/info.c @@ -768,7 +768,7 @@ infoRender(void) String *resultStr = strNew(""); // If the backup storage exists, then search for and process any stanzas - if (strLstSize(stanzaList) > 0) + if (strLstSize(stanzaList) > 0 || stanza != NULL) infoList = stanzaInfoList(stanza, stanzaList, backupLabel); // Format text output diff --git a/test/src/module/command/infoTest.c b/test/src/module/command/infoTest.c index abb681f3a..33d9c7e7f 100644 --- a/test/src/module/command/infoTest.c +++ b/test/src/module/command/infoTest.c @@ -42,6 +42,36 @@ testRun(void) harnessCfgLoad(cfgCmdInfo, argListText); TEST_RESULT_STR_Z(infoRender(), "No stanzas exist in the repository.\n", "text - no stanzas"); + // Repo is still empty but stanza option is specified + //-------------------------------------------------------------------------------------------------------------------------- + StringList *argListStanzaOpt = strLstDup(argList); + strLstAddZ(argListStanzaOpt, "--stanza=stanza1"); + harnessCfgLoad(cfgCmdInfo, argListStanzaOpt); + TEST_RESULT_STR_Z( + infoRender(), + "[" + "{" + "\"backup\":[]," + "\"db\":[]," + "\"name\":\"stanza1\"," + "\"status\":{" + "\"code\":1," + "\"lock\":{\"backup\":{\"held\":false}}," + "\"message\":\"missing stanza path\"" + "}" + "}" + "]", + "json - empty repo, stanza option specified"); + + StringList *argListTextStanzaOpt = strLstDup(argListText); + strLstAddZ(argListTextStanzaOpt, "--stanza=stanza1"); + harnessCfgLoad(cfgCmdInfo, argListTextStanzaOpt); + TEST_RESULT_STR_Z( + infoRender(), + "stanza: stanza1\n" + " status: error (missing stanza path)\n", + "text - empty repo, stanza option specified"); + storagePathCreateP(storageLocalWrite(), archivePath); storagePathCreateP(storageLocalWrite(), backupPath);