fix new test

This commit is contained in:
Andrea Spacca
2020-11-11 09:18:03 +01:00
parent 2db6465639
commit a7c8c75a49
+7 -1
View File
@@ -291,6 +291,9 @@ func TestSendTestNotificationRoute_ScriptFailure(t *testing.T) {
} }
func TestSendTestNotificationRoute_ScriptSuccess(t *testing.T) { func TestSendTestNotificationRoute_ScriptSuccess(t *testing.T) {
for _, basePath := range basePathTestCases {
t.Run(fmt.Sprintf(`with basePath "%s"`, basePath), func(tt *testing.T) {
//setup
//setup //setup
parentPath, _ := ioutil.TempDir("", "") parentPath, _ := ioutil.TempDir("", "")
defer os.RemoveAll(parentPath) defer os.RemoveAll(parentPath)
@@ -299,6 +302,7 @@ func TestSendTestNotificationRoute_ScriptSuccess(t *testing.T) {
fakeConfig := mock_config.NewMockInterface(mockCtrl) fakeConfig := mock_config.NewMockInterface(mockCtrl)
fakeConfig.EXPECT().GetString("web.database.location").AnyTimes().Return(path.Join(parentPath, "scrutiny_test.db")) 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().GetString("web.src.frontend.path").AnyTimes().Return(parentPath)
fakeConfig.EXPECT().GetString("web.src.backend.basepath").Return(basePath).AnyTimes()
fakeConfig.EXPECT().GetStringSlice("notify.urls").AnyTimes().Return([]string{"script:///usr/bin/env"}) fakeConfig.EXPECT().GetStringSlice("notify.urls").AnyTimes().Return([]string{"script:///usr/bin/env"})
ae := web.AppEngine{ ae := web.AppEngine{
Config: fakeConfig, Config: fakeConfig,
@@ -307,11 +311,13 @@ func TestSendTestNotificationRoute_ScriptSuccess(t *testing.T) {
//test //test
wr := httptest.NewRecorder() wr := httptest.NewRecorder()
req, _ := http.NewRequest("POST", "/api/health/notify", strings.NewReader("{}")) req, _ := http.NewRequest("POST", basePath + "/api/health/notify", strings.NewReader("{}"))
router.ServeHTTP(wr, req) router.ServeHTTP(wr, req)
//assert //assert
require.Equal(t, 200, wr.Code) require.Equal(t, 200, wr.Code)
})
}
} }
func TestSendTestNotificationRoute_ShoutrrrFailure(t *testing.T) { func TestSendTestNotificationRoute_ShoutrrrFailure(t *testing.T) {