Skip to content

Commit a09fc17

Browse files
committed
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
1 parent 687ad17 commit a09fc17

File tree

1 file changed

+3
-2
lines changed
  • x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message

1 file changed

+3
-2
lines changed

x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/notification/slack/message/SlackMessageTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,6 @@ public void testTemplateParseSelfGenerated() throws Exception {
461461
assertThat(parsed, equalTo(template));
462462
}
463463

464-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/31948")
465464
public void testTemplateRender() throws Exception {
466465
Settings settings = SlackMessageDefaultsTests.randomSettings();
467466
SlackMessageDefaults defaults = new SlackMessageDefaults(settings);
@@ -483,7 +482,9 @@ public void testTemplateRender() throws Exception {
483482
templateBuilder.setText(randomAlphaOfLength(10));
484483
}
485484
if (templateBuilder.text == null || randomBoolean()) {
486-
int count = randomIntBetween(0, 3);
485+
// ensure at least one attachment in the event the text is null
486+
int minimumAttachments = templateBuilder.text == null ? 1 : 0;
487+
int count = randomIntBetween(minimumAttachments, 3);
487488
for (int i = 0; i < count; i++) {
488489
Attachment.Template.Builder attachmentBuilder = createRandomAttachmentTemplateBuilder();
489490
templateBuilder.addAttachments(attachmentBuilder);

0 commit comments

Comments
 (0)