Skip to content

Commit

Permalink
Add tests for checks that was unfinished and don't have enough inform…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
volodya-lombrozo committed Apr 6, 2023
1 parent 3165f41 commit 5f7a1c7
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions src/test/java/com/jcabi/github/RtChecksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 5f7a1c7

Please sign in to comment.