Skip to content

Commit

Permalink
Send unique messages in Slack itest to avoid false positive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
llowinge authored and jamesnetherton committed Aug 25, 2020
1 parent c839c72 commit 6818dd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
Expand Down Expand Up @@ -54,8 +55,9 @@ public String getSlackMessages() throws Exception {

@Path("/message")
@POST
@Consumes(MediaType.TEXT_PLAIN)
public Response createSlackMessage(String message) throws Exception {
producerTemplate.requestBody("slack://general?" + SLACK_AUTH_PARAMS, "Hello Camel Quarkus Slack");
producerTemplate.requestBody("slack://general?" + SLACK_AUTH_PARAMS, message);
return Response
.created(new URI("https://camel.apache.org/"))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
*/
package org.apache.camel.quarkus.component.slack.it;

import java.util.UUID;

import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;

import static org.hamcrest.CoreMatchers.equalTo;
Expand All @@ -39,13 +42,21 @@ class SlackTest {

@Test
public void testSlackProduceConsumeMessages() {
RestAssured.post("/slack/message")
final String message = "Hello Camel Quarkus Slack" + (externalSlackEnabled() ? " " + UUID.randomUUID() : "");
RestAssured.given()
.contentType(ContentType.TEXT)
.body(message)
.post("/slack/message")
.then()
.statusCode(201);

RestAssured.get("/slack/messages")
.then()
.statusCode(200)
.body(equalTo("Hello Camel Quarkus Slack"));
.body(equalTo(message));
}

boolean externalSlackEnabled() {
return System.getenv("SLACK_WEBHOOK_URL") != null;
}
}

0 comments on commit 6818dd0

Please sign in to comment.