Test: Fix a second case of bad watch creation

There was still a case with a null text that allowed for 0 attachments
to be created. This commit ensures that greater than zero are created
if the text is null. Otherwise, it uses the same logic to create 0 to 3
random attachments.

Closes #31948
This commit is contained in:
Michael Basnight 2018-07-13 09:33:29 -05:00
parent b7f07f03ed
commit 1bf205f862

View File

@ -461,7 +461,6 @@ public class SlackMessageTests extends ESTestCase {
assertThat(parsed, equalTo(template));
}
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/31948")
public void testTemplateRender() throws Exception {
Settings settings = SlackMessageDefaultsTests.randomSettings();
SlackMessageDefaults defaults = new SlackMessageDefaults(settings);
@ -483,7 +482,9 @@ public class SlackMessageTests extends ESTestCase {
templateBuilder.setText(randomAlphaOfLength(10));
}
if (templateBuilder.text == null || randomBoolean()) {
int count = randomIntBetween(0, 3);
// ensure at least one attachment in the event the text is null
int minimumAttachments = templateBuilder.text == null ? 1 : 0;
int count = randomIntBetween(minimumAttachments, 3);
for (int i = 0; i < count; i++) {
Attachment.Template.Builder attachmentBuilder = createRandomAttachmentTemplateBuilder();
templateBuilder.addAttachments(attachmentBuilder);