Compare commits
2 commits
8ef1fb9dd8
...
a60ada6c08
| Author | SHA1 | Date | |
|---|---|---|---|
| a60ada6c08 | |||
| f260a25365 |
4 changed files with 39 additions and 38 deletions
|
|
@ -1,13 +1,37 @@
|
|||
name: "Build and Deploy artifact"
|
||||
on:
|
||||
push:
|
||||
branches: [master, main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: "git.lab0x13.site/scrow/bazel-java:0.12"
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/cache@v6
|
||||
with:
|
||||
path: /var/cache/bazel
|
||||
key: bazel-${{ env.FORGEJO_REPOSITORY }}
|
||||
- id: run-tests
|
||||
env:
|
||||
CACHE_USERNAME: ${{ secrets.CACHE_USERNAME }}
|
||||
CACHE_PASSWORD: ${{ secrets.CACHE_PASSWORD }}
|
||||
run: |
|
||||
bazel \
|
||||
--output_user_root=/var/cache/bazel \
|
||||
test
|
||||
--remote_cache="https://${CACHE_USERNAME}:${CACHE_PASSWORD}@cache.lab0x13.site:443" \
|
||||
--noremote_upload_local_results \
|
||||
--noremote_cache_async \
|
||||
//... --test_output=all
|
||||
|
||||
deploy:
|
||||
needs: test
|
||||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main'
|
||||
runs-on: docker
|
||||
container:
|
||||
image: "git.lab0x13.site/scrow/bazel-java:0.12"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/cache@v6
|
||||
|
|
@ -29,4 +53,4 @@ jobs:
|
|||
--remote_cache="https://${CACHE_USERNAME}:${CACHE_PASSWORD}@cache.lab0x13.site:443" \
|
||||
--remote_upload_local_results \
|
||||
--noremote_cache_async
|
||||
done
|
||||
done
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: "git.lab0x13.site/scrow/bazel-java:0.12"
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
- uses: actions/cache@v6
|
||||
with:
|
||||
path: /var/cache/bazel
|
||||
key: bazel-${{ env.FORGEJO_REPOSITORY }}
|
||||
- id: run-tests
|
||||
env:
|
||||
CACHE_USERNAME: ${{ secrets.CACHE_USERNAME }}
|
||||
CACHE_PASSWORD: ${{ secrets.CACHE_PASSWORD }}
|
||||
run: |
|
||||
bazel \
|
||||
--output_user_root=/var/cache/bazel \
|
||||
test
|
||||
--remote_cache="https://${CACHE_USERNAME}:${CACHE_PASSWORD}@cache.lab0x13.site:443" \
|
||||
--noremote_upload_local_results \
|
||||
--noremote_cache_async \
|
||||
//common/tests:site/lab0x13/scrow/commands/CommandHandlerTest --test_output=all --test_verbose_timeout_warnings
|
||||
|
|
@ -13,6 +13,7 @@ import site.lab0x13.scrow.commands.model.literal.RootLiteral;
|
|||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
|
@ -56,7 +57,7 @@ class CommandHandlerTest {
|
|||
|
||||
@BeforeAll
|
||||
static void init() {
|
||||
System.setOut(new PrintStream(outContent));
|
||||
System.setOut(new PrintStream(outContent, true, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
|
|
@ -72,37 +73,37 @@ class CommandHandlerTest {
|
|||
@Test
|
||||
void testDefaultExecutor() {
|
||||
commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of());
|
||||
assertEquals("default executor\n", outContent.toString());
|
||||
assertEquals("default executor\n", outContent.toString(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSubLiteralNoArgs() {
|
||||
commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of("get", "foo"));
|
||||
assertEquals("get executor: player=foo\n", outContent.toString());
|
||||
assertEquals("get executor: player=foo\n", outContent.toString(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSubLiteralWithArgs() {
|
||||
commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of("set", "foo", "10"));
|
||||
assertEquals("set executor: player=foo amount=10\n", outContent.toString());
|
||||
assertEquals("set executor: player=foo amount=10\n", outContent.toString(StandardCharsets.UTF_8));
|
||||
outContent.reset();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailOnBadLiteral() {
|
||||
commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of("BAD_LITERAL"));
|
||||
assertEquals("Unknown literal \"BAD_LITERAL\".\n", outContent.toString());
|
||||
assertEquals("Unknown literal \"BAD_LITERAL\".\n", outContent.toString(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailOnBadArgument() {
|
||||
commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of("set", "foo", "bar"));
|
||||
assertEquals("Not a number.\n", outContent.toString());
|
||||
assertEquals("Not a number.\n", outContent.toString(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFailOnMissingArgument() {
|
||||
commandHandler.invoke(rootLiteral, new CommandContextImpl(), Stream.of("set"));
|
||||
assertEquals("Argument expected.\n", outContent.toString());
|
||||
assertEquals("Argument expected.\n", outContent.toString(StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package site.lab0x13.scrow.commands;
|
|||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestPlatform implements PlatformAdapter<CommandContextImpl> {
|
||||
|
|
@ -12,7 +13,7 @@ public class TestPlatform implements PlatformAdapter<CommandContextImpl> {
|
|||
private final List<String> permissions;
|
||||
|
||||
public TestPlatform(List<String> permissions) {
|
||||
this.permissions = permissions;
|
||||
this.permissions = new ArrayList<>(permissions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -23,5 +24,6 @@ public class TestPlatform implements PlatformAdapter<CommandContextImpl> {
|
|||
@Override
|
||||
public void sendMessage(CommandContextImpl ctx, Component message) {
|
||||
System.out.println(plainText.serialize(message));
|
||||
System.out.flush();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue