From 4641feec03e768a70bf2b64773a511972c8c8193 Mon Sep 17 00:00:00 2001 From: Fedor Rumyantsev Date: Thu, 18 May 2023 14:29:28 +0200 Subject: [PATCH] fix up tests for 2023.05 release --- .../slackNotifier/BaseSlackTestCase.kt | 12 ------------ .../notification/SlackNotifierTest.kt | 15 +++++++++++---- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/integration-tests/src/test/kotlin/jetbrains/buildServer/notification/slackNotifier/BaseSlackTestCase.kt b/integration-tests/src/test/kotlin/jetbrains/buildServer/notification/slackNotifier/BaseSlackTestCase.kt index 6cee978..50975fa 100644 --- a/integration-tests/src/test/kotlin/jetbrains/buildServer/notification/slackNotifier/BaseSlackTestCase.kt +++ b/integration-tests/src/test/kotlin/jetbrains/buildServer/notification/slackNotifier/BaseSlackTestCase.kt @@ -542,18 +542,6 @@ open class BaseSlackTestCase : BaseNotificationRulesTestCase() { assertTrue(mySlackApi.messages.last().text!!.length < 1000) } - fun `then exception is logged in the build log`(exceptionMessage: String) { - val prefix = "Service message notification exception: " - val errorMessages = runningBuild.buildLog.errorMessages - val exceptions = errorMessages - .filter {it.text.contains(prefix)} - .map { it.text } - assertEquals( - listOf(prefix + exceptionMessage), - exceptions - ) - } - private fun waitForMessage() { waitForAssert(BooleanSupplier { mySlackApi.messages.isNotEmpty() diff --git a/integration-tests/src/test/kotlin/jetbrains/buildServer/notification/slackNotifier/notification/SlackNotifierTest.kt b/integration-tests/src/test/kotlin/jetbrains/buildServer/notification/slackNotifier/notification/SlackNotifierTest.kt index a920432..061a73a 100644 --- a/integration-tests/src/test/kotlin/jetbrains/buildServer/notification/slackNotifier/notification/SlackNotifierTest.kt +++ b/integration-tests/src/test/kotlin/jetbrains/buildServer/notification/slackNotifier/notification/SlackNotifierTest.kt @@ -257,7 +257,7 @@ class SlackNotifierTest : BaseSlackTestCase() { @Test fun `service message notification should fail if no connections allow it`() { `when service message notification is sent`() - `then exception is logged in the build log`("Could not find any suitable Slack connection with service message notifications enabled") + 0.`messages should be sent`() } @Test @@ -271,21 +271,28 @@ class SlackNotifierTest : BaseSlackTestCase() { fun `service message notification should fail if more than one connection allow it`() { `given there are more multiple connections allowing service message notifications`() `when service message notification is sent`() - `then exception is logged in the build log`("More than one suitable Slack connection was found, please specify 'connectionId' argument to explicitly select connection") + 0.`messages should be sent`() } @Test fun `service message notification should fail if notification limit is reached`() { `given there is connection allowing service message notifications`(1) `when multiple service message notifications are sent`(count = 2) - `then exception is logged in the build log`("Reached limit of 1 service message Slack notifications per build") + 1.`messages should be sent`() + } + + @Test + fun `service message notification should honor -1 notification limit`() { + `given there is connection allowing service message notifications`(-1) + `when service message notification is sent`() + `then message should contain`("service message") } @Test fun `service message notification should fail if there are external domains not in whitelist`() { `given there is connection allowing service message notifications`(1) `when service message notification is sent`(message = "link to externaldomain.com") - `then exception is logged in the build log`("Found external domains that are not allowed by configuration: [externaldomain.com]") + 0.`messages should be sent`() } @Test