Add a test for ambiguous command registration

This commit is contained in:
jmp 2020-10-26 12:56:27 -07:00 committed by Alexander Söderberg
parent 5e27148d82
commit f1cc2689a0

View file

@ -31,6 +31,7 @@ import cloud.commandframework.arguments.standard.FloatArgument;
import cloud.commandframework.arguments.standard.IntegerArgument;
import cloud.commandframework.arguments.standard.StringArgument;
import cloud.commandframework.context.CommandContext;
import cloud.commandframework.exceptions.AmbiguousNodeException;
import cloud.commandframework.exceptions.NoPermissionException;
import cloud.commandframework.meta.SimpleCommandMeta;
import cloud.commandframework.types.tuples.Pair;
@ -288,6 +289,16 @@ class CommandTreeTest {
manager.executeCommand(new TestCommandSender(), "flags -tf --num 63 --enum potato").join();
}
@Test
void testAmbiguousNodes() {
manager.command(manager.commandBuilder("ambiguous")
.argument(StringArgument.of("string"))
);
Assertions.assertThrows(AmbiguousNodeException.class, () ->
manager.command(manager.commandBuilder("ambiguous")
.argument(IntegerArgument.of("integer"))));
}
@Test
void testDuplicateArgument() {
final CommandArgument<TestCommandSender, String> argument = StringArgument.of("test");