fix import. added simle test for notify test endpoint.

pull/28/head
Jason Kulatunga 4 years ago
parent 78a619b09d
commit 98415e625d

@ -49,7 +49,7 @@ notify:
- "hangouts://chat.googleapis.com/v1/spaces/FOO/messages?key=bar&token=baz"
- "zulip://bot-mail:bot-key@zulip-domain/?stream=name-or-id&topic=name"
- "join://shoutrrr:api-key@join/?devices=device1[,device2, ...][&icon=icon][&title=title]"
- "script:///file/path/on/disk" #note the triple slashes "script:///"
- "script:///file/path/on/disk"
- "https://www.example.com/path"
collect:

@ -4,7 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/AnalogJ/go-util/utils"
"github.com/analogj/go-util/utils"
"github.com/analogj/scrutiny/webapp/backend/pkg/config"
"github.com/containrrr/shoutrrr"
log "github.com/sirupsen/logrus"

@ -8,6 +8,7 @@ import (
"net/http"
"net/http/httptest"
"os"
"strings"
"testing"
)
@ -147,3 +148,25 @@ func TestPopulateMultiple(t *testing.T) {
//assert
}
func TestSendTestNotificationRoute(t *testing.T) {
//setup
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()
fakeConfig := mock_config.NewMockInterface(mockCtrl)
fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return("testdata/scrutiny_test.db")
fakeConfig.EXPECT().GetString("web.src.frontend.path").AnyTimes().Return("testdata")
fakeConfig.EXPECT().GetStringSlice("notify.urls").AnyTimes().Return([]string{"https://scrutiny.requestcatcher.com/test"})
ae := web.AppEngine{
Config: fakeConfig,
}
router := ae.Setup()
//test
wr := httptest.NewRecorder()
req, _ := http.NewRequest("POST", "/api/health/notify", strings.NewReader("{}"))
router.ServeHTTP(wr, req)
//assert
require.Equal(t, 200, wr.Code)
}

Loading…
Cancel
Save