Skip to content

Commit

Permalink
improved failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Wells <[email protected]>
  • Loading branch information
matthewryanwells committed Jul 26, 2023
1 parent 3704dc4 commit 3a11f9d
Showing 1 changed file with 2 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.opensearch.client.Request;
import org.opensearch.client.RequestOptions;
import org.opensearch.client.Response;
import org.opensearch.client.ResponseException;
import org.opensearch.sql.common.utils.StringUtils;
import org.opensearch.sql.legacy.SQLIntegTestCase;

Expand Down Expand Up @@ -1359,22 +1360,7 @@ public void testBracketedEquivalent() throws IOException {
}

private void queryFails(String query) {
Request request = new Request("POST", QUERY_API_ENDPOINT);
request.setJsonEntity(String.format(Locale.ROOT, "{\n" + " \"query\": \"%s\"\n" + "}", query));

RequestOptions.Builder restOptionsBuilder = RequestOptions.DEFAULT.toBuilder();
restOptionsBuilder.addHeader("Content-Type", "application/json");
request.setOptions(restOptionsBuilder);

boolean fails = false;

try {
client().performRequest(request);
} catch(Exception ignored) {
fails = true;
}

assertTrue(fails);
assertThrows(ResponseException.class, ()->executeQuery(query));
}

@Test
Expand All @@ -1385,6 +1371,5 @@ public void testBracketFails() {
queryFails("select {d 'failure'}");
queryFails("select {timestamp 'failure'}");
queryFails("select {ts 'failure'}");

}
}

0 comments on commit 3a11f9d

Please sign in to comment.