From b0cf6d0d2f391ae73dedc82de6bafe6a62e6dc15 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 31 Jul 2021 05:13:51 +0800 Subject: [PATCH] [GH-443] Add unit tests for ./services/webhook/webhook.go (#710) * Add unit tests for ./services/webhook/webhook.go * fix logger in TestClientUpdateNotify * make ci happy Co-authored-by: Doug Lauder Co-authored-by: Scott Bishel --- server/services/webhook/webhook_test.go | 31 +++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 server/services/webhook/webhook_test.go diff --git a/server/services/webhook/webhook_test.go b/server/services/webhook/webhook_test.go new file mode 100644 index 000000000..c37d4be13 --- /dev/null +++ b/server/services/webhook/webhook_test.go @@ -0,0 +1,31 @@ +package webhook + +import ( + "net/http" + "net/http/httptest" + "testing" + + "github.com/mattermost/focalboard/server/model" + "github.com/mattermost/focalboard/server/services/config" + "github.com/mattermost/focalboard/server/services/mlog" +) + +func TestClientUpdateNotify(t *testing.T) { + var isNotified bool + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + isNotified = true + })) + defer ts.Close() + + cfg := &config.Configuration{ + WebhookUpdate: []string{ts.URL}, + } + + client := NewClient(cfg, mlog.CreateTestLogger(t)) + + client.NotifyUpdate(model.Block{}) + + if !isNotified { + t.Error("webhook url not be notified") + } +}