2018-01-28 18:09:08 +01:00
|
|
|
from zerver.lib.test_classes import WebhookTestCase
|
|
|
|
|
2020-01-14 22:06:24 +01:00
|
|
|
|
2018-01-28 18:09:08 +01:00
|
|
|
class GocdHookTests(WebhookTestCase):
|
2024-05-04 22:02:50 +02:00
|
|
|
CHANNEL_NAME = "gocd"
|
2018-01-28 18:09:08 +01:00
|
|
|
URL_TEMPLATE = "/api/v1/external/gocd?stream={stream}&api_key={api_key}"
|
2021-06-26 09:18:33 +02:00
|
|
|
WEBHOOK_DIR_NAME = "gocd"
|
2024-01-30 02:11:11 +01:00
|
|
|
|
|
|
|
def test_building_pipeline(self) -> None:
|
|
|
|
expected_topic = "Pipeline / Stage"
|
|
|
|
expected_message = """**Pipeline building**: Pipeline / Stage
|
|
|
|
- **Commit**: [`59f3c6e4540`](https://github.com/swayam0322/Test/commit/59f3c6e4540) on branch `main`
|
|
|
|
- **Started**: Feb 1, 2024, 1:58:13 AM"""
|
2018-01-28 18:09:08 +01:00
|
|
|
|
2020-08-23 15:49:24 +02:00
|
|
|
self.check_webhook(
|
2024-01-30 02:11:11 +01:00
|
|
|
"pipeline_building",
|
|
|
|
expected_topic,
|
2018-01-28 18:09:08 +01:00
|
|
|
expected_message,
|
|
|
|
)
|
|
|
|
|
2024-01-30 02:11:11 +01:00
|
|
|
def test_completed_pipeline_success(self) -> None:
|
|
|
|
expected_topic = "Pipeline / Stage"
|
|
|
|
expected_message = """:green_circle: **Build passed**: Pipeline / Stage
|
|
|
|
- **Commit**: [`59f3c6e4540`](https://github.com/swayam0322/Test/commit/59f3c6e4540) on branch `main`
|
|
|
|
- **Started**: Feb 1, 2024, 1:58:13 AM
|
|
|
|
- **Finished**: Feb 1, 2024, 1:58:40 AM
|
|
|
|
- **Passed**: `Job`"""
|
2018-01-28 18:09:08 +01:00
|
|
|
|
2024-01-30 02:11:11 +01:00
|
|
|
self.check_webhook("pipeline_passed", expected_topic, expected_message)
|
|
|
|
|
|
|
|
def test_completed_pipeline_fail(self) -> None:
|
|
|
|
expected_topic = "pipeline-one / stage-two"
|
|
|
|
expected_message = """:red_circle: **Build failed**: pipeline-one / stage-two
|
|
|
|
- **Commit**: [`963eb239c7b`](https://github.com/PieterCK/getting-started-repo.git/commit/963eb239c7b) on branch `master`
|
|
|
|
- **Started**: Aug 28, 2024, 9:30:19 PM
|
|
|
|
- **Finished**: Aug 28, 2024, 9:31:00 PM
|
|
|
|
- **Failed**: `task-two`"""
|
|
|
|
self.check_webhook("pipeline_failed", expected_topic, expected_message)
|
|
|
|
|
|
|
|
def test_completed_pipeline_with_mixed_result(self) -> None:
|
|
|
|
expected_topic = "test-pipeline / backend-tests"
|
|
|
|
expected_message = """:red_circle: **Build failed**: test-pipeline / backend-tests
|
|
|
|
- **Commit**: [`963eb239c7b`](https://github.com/PieterCK/getting-started-repo.git/commit/963eb239c7b) on branch `master`
|
|
|
|
- **Started**: Aug 29, 2024, 3:59:18 PM
|
|
|
|
- **Finished**: Aug 29, 2024, 4:00:15 PM
|
|
|
|
- **Failed**: `check-backend-lints`, `test-frontend-js`
|
|
|
|
- **Passed**: `check-backend-tests`, `zulip-ci-debian-12`"""
|
|
|
|
self.check_webhook("pipeline_with_mixed_job_result", expected_topic, expected_message)
|