Skip to content

Commit f438921

Browse files
Filled in the testEditHandler, but it will send back a 500 error beca… (#337)
* Filled in the testEditHandler, but it will send back a 500 error because of the websocket upgrade thing. * fixed the test
1 parent 6455e3b commit f438921

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,44 @@
11
package tests
22

33
import (
4+
"net/http"
5+
"net/http/httptest"
46
"testing"
7+
8+
repMocks "cms.csesoc.unsw.edu.au/database/repositories/mocks"
9+
"cms.csesoc.unsw.edu.au/endpoints"
10+
"cms.csesoc.unsw.edu.au/endpoints/mocks"
11+
"cms.csesoc.unsw.edu.au/endpoints/models"
12+
"cms.csesoc.unsw.edu.au/internal/logger"
13+
"github.com/golang/mock/gomock"
14+
"github.com/google/uuid"
15+
"github.com/stretchr/testify/assert"
516
)
617

18+
// Currently failing, because the websocket upgrade thing fails and will send back a 500 error.
719
func TestEditHandler(t *testing.T) {
20+
controller := gomock.NewController(t);
21+
assert := assert.New(t)
22+
defer controller.Finish()
23+
24+
// Test Setup
25+
documentID := uuid.New()
26+
form := models.ValidEditRequest{DocumentID: documentID}
27+
responseRecorder := httptest.NewRecorder();
28+
request := httptest.NewRequest("GET", "/editor", nil)
29+
30+
//Make unpublishedvolumes
31+
mockUnpublishedVolume := repMocks.NewMockIUnpublishedVolumeRepository(controller)
32+
33+
// Make logger
34+
log := logger.OpenLog("New Handler Log")
35+
mockDepFactory := mocks.NewMockDependencyFactory(controller)
36+
mockDepFactory.EXPECT().GetLogger().Return(log)
37+
mockDepFactory.EXPECT().GetUnpublishedVolumeRepo().Return(mockUnpublishedVolume)
38+
39+
// Test execution
40+
response := endpoints.EditHandler(form, responseRecorder, request, mockDepFactory)
41+
assert.Equal(response.Status, http.StatusInternalServerError)
842
}
943

44+

0 commit comments

Comments
 (0)