From 93cf67681821b0fc4ca1ad9a88aa2ae81d6d1820 Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Tue, 3 Nov 2020 08:20:02 -0800 Subject: [PATCH] added a "Success" test for script notifications. bumping the version in version file? not sure why it wasnt correctly bumped already. --- webapp/backend/pkg/version/version.go | 2 +- webapp/backend/pkg/web/server_test.go | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/webapp/backend/pkg/version/version.go b/webapp/backend/pkg/version/version.go index 5b7ecf9..0ea0307 100644 --- a/webapp/backend/pkg/version/version.go +++ b/webapp/backend/pkg/version/version.go @@ -2,4 +2,4 @@ package version // VERSION is the app-global version string, which will be replaced with a // new value during packaging -const VERSION = "0.3.0" +const VERSION = "0.3.1" diff --git a/webapp/backend/pkg/web/server_test.go b/webapp/backend/pkg/web/server_test.go index adb7b12..1b2d87f 100644 --- a/webapp/backend/pkg/web/server_test.go +++ b/webapp/backend/pkg/web/server_test.go @@ -237,6 +237,30 @@ func TestSendTestNotificationRoute_ScriptFailure(t *testing.T) { require.Equal(t, 500, wr.Code) } +func TestSendTestNotificationRoute_ScriptSuccess(t *testing.T) { + //setup + parentPath, _ := ioutil.TempDir("", "") + defer os.RemoveAll(parentPath) + mockCtrl := gomock.NewController(t) + defer mockCtrl.Finish() + fakeConfig := mock_config.NewMockInterface(mockCtrl) + fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return(path.Join(parentPath, "scrutiny_test.db")) + fakeConfig.EXPECT().GetString("web.src.frontend.path").AnyTimes().Return(parentPath) + fakeConfig.EXPECT().GetStringSlice("notify.urls").AnyTimes().Return([]string{"script:///usr/bin/env"}) + ae := web.AppEngine{ + Config: fakeConfig, + } + router := ae.Setup(logrus.New()) + + //test + wr := httptest.NewRecorder() + req, _ := http.NewRequest("POST", "/api/health/notify", strings.NewReader("{}")) + router.ServeHTTP(wr, req) + + //assert + require.Equal(t, 200, wr.Code) +} + func TestSendTestNotificationRoute_ShoutrrrFailure(t *testing.T) { //setup parentPath, _ := ioutil.TempDir("", "")