Skip to content

Commit

Permalink
Modified test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sarvekshayr committed Dec 18, 2024
1 parent d02a5ec commit 26f1c86
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
* Ozone Repair Command line tool.
*/
@CommandLine.Command(name = "ozone repair",
description = "Repair is an advanced operation and the nodes being repaired should be stopped while it is running",
description = "Repair is an advanced operation and the nodes being repaired " +
"should be stopped while it is running.",
versionProvider = HddsVersionProvider.class,
mixinStandardHelpOptions = true)
public class OzoneRepair extends GenericCli implements ExtensibleParentCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void testOzoneRepairWhenUserIsRemindedSystemUserAndDeclinesToProceed() throws Ex
OzoneRepair ozoneRepair = new OzoneRepair();
System.setIn(new ByteArrayInputStream("N".getBytes(DEFAULT_ENCODING)));

int res = ozoneRepair.execute(new String[]{});
int res = ozoneRepair.execute(new String[]{"om", "fso-tree"});
assertEquals(1, res);
assertThat(out.toString(DEFAULT_ENCODING)).contains("Aborting command.");
// prompt should contain the current user name as well
Expand All @@ -79,10 +79,19 @@ void testOzoneRepairWhenUserIsRemindedSystemUserAndAgreesToProceed() throws Exce
OzoneRepair ozoneRepair = new OzoneRepair();
System.setIn(new ByteArrayInputStream("y".getBytes(DEFAULT_ENCODING)));

ozoneRepair.execute(new String[]{});
ozoneRepair.execute(new String[]{"om", "fso-tree"});
assertThat(out.toString(DEFAULT_ENCODING)).contains("Run as user: " + OZONE_USER);
// prompt should contain the current user name as well
assertThat(err.toString(DEFAULT_ENCODING)).contains("ATTENTION: Running as user " + OZONE_USER);
}

@Test
void testOzoneRepairSkipsPromptWhenNoSubcommandProvided() throws Exception {
OzoneRepair ozoneRepair = new OzoneRepair();

// when no argument is passed, prompt should not be displayed
ozoneRepair.execute(new String[]{});
assertThat(err.toString(DEFAULT_ENCODING)).doesNotContain("ATTENTION: Running as user " + OZONE_USER);
}

}

0 comments on commit 26f1c86

Please sign in to comment.