gnodet-bot commented on code in PR #29804:
URL: https://github.com/apache/camel/pull/29804#discussion_r4566059249
##########
dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/common/GitHubApiResponseTest.java:
##########
@@ -94,4 +108,106 @@ void trailingContentAndNonTextNamesAreTolerated() throws
Exception {
assertThat(all).hasToString(GitHubHelper.asGithubSingleUrl("https://github.com/me/repo/blob/main/route.java"));
}
+
+ @Test
+ void nonOkGithubResponseThrows() {
+ statusCode = 404;
+
+ assertThatThrownBy(() -> GitHubHelper.resolveGithubAsRawFiles(url,
null, null, null, null, new StringJoiner(",")))
+ .isInstanceOf(IOException.class)
Review Comment:
💡 `nonOkGithubResponseThrows` asserts `IOException` but the production code
throws `FileNotFoundException` for 404 — a subtype, so this passes today. If
the production code ever regresses to throwing a plain `IOException`, the test
still passes and the exit-66 mapping silently breaks. Assert the more specific
type.
```suggestion
.isInstanceOf(FileNotFoundException.class)
```
##########
dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/common/GitHubApiResponseTest.java:
##########
@@ -94,4 +108,106 @@ void trailingContentAndNonTextNamesAreTolerated() throws
Exception {
assertThat(all).hasToString(GitHubHelper.asGithubSingleUrl("https://github.com/me/repo/blob/main/route.java"));
}
+
+ @Test
+ void nonOkGithubResponseThrows() {
+ statusCode = 404;
+
+ assertThatThrownBy(() -> GitHubHelper.resolveGithubAsRawFiles(url,
null, null, null, null, new StringJoiner(",")))
+ .isInstanceOf(IOException.class)
+ .hasMessageContaining("404");
+ }
+
+ @Test
+ void accessDeniedGithubResponseThrowsWithHint() {
+ statusCode = 403;
+
+ assertThatThrownBy(() -> GitHubHelper.resolveGithubAsRawFiles(url,
null, null, null, null, new StringJoiner(",")))
+ .isInstanceOf(IOException.class)
+ .hasMessageContaining("403")
+ .hasMessageContaining("access denied");
+ }
+
+ @Test
+ void rateLimitExhaustedGithubResponseThrowsWithHint() {
+ statusCode = 403;
+ rateLimitRemaining = "0";
+
+ assertThatThrownBy(() -> GitHubHelper.resolveGithubAsRawFiles(url,
null, null, null, null, new StringJoiner(",")))
+ .isInstanceOf(IOException.class)
+ .hasMessageContaining("403")
+ .hasMessageContaining("rate limit exceeded");
+ }
+
+ @Test
+ void nonOkGistResponseThrows() {
+ statusCode = 404;
+
+ assertThatThrownBy(() -> GistHelper.resolveGistAsRawFiles(url, null,
null, null, new StringJoiner(",")))
+ .isInstanceOf(IOException.class)
Review Comment:
💡 Same issue in `nonOkGistResponseThrows` — assert `FileNotFoundException`
to lock in the type.
```suggestion
.isInstanceOf(FileNotFoundException.class)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]