Skip to content

Commit

Permalink
[improve][fn] Set default tenant and namespace for ListFunctions cmd (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangpengcheng authored Jan 24, 2025
1 parent 0f9f661 commit 66d1bb0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,19 @@ public void testListFunctions() throws Exception {
verify(functions, times(1)).getFunctions(eq(TENANT), eq(NAMESPACE));
}

@Test
public void testListFunctionsWithDefaultValue() throws Exception {
cmd.run(new String[] {
"list",
});

ListFunctions lister = cmd.getLister();
assertEquals("public", lister.getTenant());
assertEquals("default", lister.getNamespace());

verify(functions, times(1)).getFunctions(eq("public"), eq("default"));
}

@Test
public void testStateGetter() throws Exception {
String key = TEST_NAME + "-key";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ abstract class NamespaceCommand extends BaseCommand {

@Option(names = "--namespace", description = "The namespace of a Pulsar Function")
protected String namespace;

@Override
public void processArguments() {
if (tenant == null) {
tenant = PUBLIC_TENANT;
}
if (namespace == null) {
namespace = DEFAULT_NAMESPACE;
}
}
}

/**
Expand Down

0 comments on commit 66d1bb0

Please sign in to comment.