From 5f7a1c7cacebb47bfbfa05e33ebeccf4ba110526 Mon Sep 17 00:00:00 2001 From: volodya-lombrozo Date: Thu, 6 Apr 2023 22:19:16 +0300 Subject: [PATCH] Add tests for checks that was unfinished and don't have enough information --- .../java/com/jcabi/github/RtChecksTest.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/src/test/java/com/jcabi/github/RtChecksTest.java b/src/test/java/com/jcabi/github/RtChecksTest.java index ab7b32b5c..4fd661978 100644 --- a/src/test/java/com/jcabi/github/RtChecksTest.java +++ b/src/test/java/com/jcabi/github/RtChecksTest.java @@ -138,6 +138,71 @@ public void assertsOkResponse() throws IOException { } } + @Test + public void retrievesUnfinishedChecksWithoutConclusion() throws IOException { + try (final MkContainer container = new MkGrizzlyContainer() + .next( + new MkAnswer.Simple( + HttpURLConnection.HTTP_OK, + Json.createObjectBuilder() + .add("total_count", Json.createValue(1)) + .add("check_runs", + Json.createArrayBuilder() + .add( + Json.createObjectBuilder() + .add("id", Json.createValue(new Random().nextInt())) + .add("status", "completed") + .build() + ) + ) + .build() + .toString() + ) + ).start(this.resource.port()) + ) { + final Checks checks = new RtChecks( + new JdkRequest(container.home()), + this.repo().pulls().get(0) + ); + MatcherAssert.assertThat(checks.all(), Matchers.hasSize(1)); + for (final Check check : checks.all()) { + MatcherAssert.assertThat(check.successful(), Matchers.is(false)); + } + } + } + + @Test + public void retrievesUnfinishedChecksWithoutStatusAndConclusion() throws IOException { + try (final MkContainer container = new MkGrizzlyContainer() + .next( + new MkAnswer.Simple( + HttpURLConnection.HTTP_OK, + Json.createObjectBuilder() + .add("total_count", Json.createValue(1)) + .add("check_runs", + Json.createArrayBuilder() + .add( + Json.createObjectBuilder() + .add("id", Json.createValue(new Random().nextInt())) + .build() + ) + ) + .build() + .toString() + ) + ).start(this.resource.port()) + ) { + final Checks checks = new RtChecks( + new JdkRequest(container.home()), + this.repo().pulls().get(0) + ); + MatcherAssert.assertThat(checks.all(), Matchers.hasSize(1)); + for (final Check check : checks.all()) { + MatcherAssert.assertThat(check.successful(), Matchers.is(false)); + } + } + } + /** * Creates json response body. *