Skip to content

Commit 8a22142

Browse files
committed
test(bigquery): Fix flaky ITBigQueryTest#testProjectIDFastSQLQueryWithJobId
This PR fixes a flaky integration test by replacing a strict string assertion on a backend error message ("Cannot parse as CloudRegion.") with a more robust assertion on the HTTP status code (400 Bad Request) and a flexible substring check. Fixes #12135
1 parent 52e041a commit 8a22142

File tree

1 file changed

+4
-2
lines changed
  • java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it

1 file changed

+4
-2
lines changed

java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/it/ITBigQueryTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4700,10 +4700,12 @@ void testProjectIDFastSQLQueryWithJobId() {
47004700
QueryJobConfiguration.newBuilder(query).setDefaultDataset(DatasetId.of(DATASET)).build();
47014701
try {
47024702
bigquery.query(configSelect, jobIdWithProjectId);
4703+
fail("Expected BigQueryException to be thrown");
47034704
} catch (Exception exception) {
4704-
// error message for non-existent project
4705-
assertEquals("Cannot parse as CloudRegion.", exception.getMessage());
47064705
assertEquals(BigQueryException.class, exception.getClass());
4706+
BigQueryException bqException = (BigQueryException) exception;
4707+
assertEquals(400, bqException.getCode());
4708+
assertTrue(bqException.getMessage().contains("CloudRegion"));
47074709
}
47084710
}
47094711

0 commit comments

Comments
 (0)