diff options
| author | Shulhan <ms@kilabit.info> | 2025-08-29 01:37:28 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2025-09-26 13:59:58 +0700 |
| commit | 62161730b5802c4206f0cc169a744b364576bb74 (patch) | |
| tree | 914389da9748b3b7cff731357deff7026273d22f /worker_test.go | |
| parent | b6530117f0dcc554114bfac8b86d9fb1fde605c4 (diff) | |
| download | lilin-62161730b5802c4206f0cc169a744b364576bb74.tar.xz | |
all: implement notification using Mattermost incoming webhook
In the server configuration, one can defined the following section
to send the notification using Mattermost,
[notif]
kind = mattermost
webhook_url = # The incoming webhook URL.
channel = # The channel where the notification will be placed.
down_template = # Message template when service is down.
up_template = # Message template when service is up.
Diffstat (limited to 'worker_test.go')
| -rw-r--r-- | worker_test.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/worker_test.go b/worker_test.go index c00339c..833322c 100644 --- a/worker_test.go +++ b/worker_test.go @@ -94,3 +94,32 @@ func TestNewWorker(t *testing.T) { test.Assert(t, `worker.Services`, tcase.expServices, wrk.Services) } } + +func TestWorker_pushNotifMattermost(t *testing.T) { + var serverCfg = &ServerConfig{ + BaseDir: `testdata/worker/pushNotifMattermost`, + } + + var err = serverCfg.init() + if err != nil { + t.Fatal(err) + } + + var notifCfgMattermost = serverCfg.Notifs[0] + + var wrk *worker + wrk, err = newWorker(*serverCfg) + if err != nil { + t.Fatal(err) + } + + var scanReport = &ScanReport{ + ID: `dummy_http`, + Error: `503 internal server error`, + } + wrk.pushNotifMattermost(notifCfgMattermost, scanReport) + + var gotRequestBody = <-dhs.reqbodyq + var expRequestBody = `{"channel":"test_webhook","text":"Service dummy_http is down: 503 internal server error"}` + test.Assert(t, `request body`, expRequestBody, string(gotRequestBody)) +} |
