Update SendMessage for new protocol
This commit is contained in:
@@ -1,5 +1 @@
|
||||
package web
|
||||
|
||||
type SendMessageResponse struct {
|
||||
Guid string `json:"guid"`
|
||||
}
|
||||
|
||||
@@ -248,13 +248,8 @@ func (m *MockHTTPServer) handleSendMessage(w http.ResponseWriter, r *http.Reques
|
||||
// Send message
|
||||
m.Server.SendMessage(conversation, message)
|
||||
|
||||
// Formulate response
|
||||
sendMessageResp := SendMessageResponse{
|
||||
Guid: message.Guid,
|
||||
}
|
||||
|
||||
// Encode response as JSON
|
||||
jsonData, err := json.Marshal(sendMessageResp)
|
||||
jsonData, err := json.Marshal(message)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error marshalling response")
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
|
||||
@@ -118,7 +118,7 @@ func TestMessages(t *testing.T) {
|
||||
|
||||
server.Server.AppendMessageToConversation(&conversation, message)
|
||||
|
||||
resp, err := http.Get(httpServer.URL + "/messages?guid=" + *&conversation.Guid)
|
||||
resp, err := http.Get(httpServer.URL + "/messages?guid=" + conversation.Guid)
|
||||
if err != nil {
|
||||
t.Fatalf("TestMessages error: %s", err)
|
||||
}
|
||||
@@ -237,7 +237,7 @@ func TestAuthentication(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestUpdates(t *testing.T) {
|
||||
s := web.NewMockHTTPServer(web.MockHTTPServerConfiguration{AuthEnabled: true})
|
||||
s := web.NewMockHTTPServer(web.MockHTTPServerConfiguration{AuthEnabled: false})
|
||||
httpServer := httptest.NewServer(s)
|
||||
|
||||
messageSeq := 0
|
||||
@@ -396,7 +396,7 @@ func TestUpdatesWebsocket(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMarkConversation(t *testing.T) {
|
||||
s := web.NewMockHTTPServer(web.MockHTTPServerConfiguration{AuthEnabled: true})
|
||||
s := web.NewMockHTTPServer(web.MockHTTPServerConfiguration{AuthEnabled: false})
|
||||
httpServer := httptest.NewServer(s)
|
||||
|
||||
// Mock conversation
|
||||
@@ -439,7 +439,7 @@ func TestMarkConversation(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMessageQueries(t *testing.T) {
|
||||
s := web.NewMockHTTPServer(web.MockHTTPServerConfiguration{AuthEnabled: true})
|
||||
s := web.NewMockHTTPServer(web.MockHTTPServerConfiguration{AuthEnabled: false})
|
||||
httpServer := httptest.NewServer(s)
|
||||
|
||||
// Mock conversation
|
||||
@@ -536,7 +536,7 @@ func TestMessageQueries(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSendMessage(t *testing.T) {
|
||||
s := web.NewMockHTTPServer(web.MockHTTPServerConfiguration{AuthEnabled: true})
|
||||
s := web.NewMockHTTPServer(web.MockHTTPServerConfiguration{AuthEnabled: false})
|
||||
httpServer := httptest.NewServer(s)
|
||||
|
||||
// Mock conversation
|
||||
@@ -578,7 +578,7 @@ func TestSendMessage(t *testing.T) {
|
||||
t.Fatalf("Error decoding body: %s", body)
|
||||
}
|
||||
|
||||
var response web.SendMessageResponse
|
||||
var response model.Message
|
||||
err = json.Unmarshal(body, &response)
|
||||
if err != nil {
|
||||
t.Fatalf("Error unmarshalling JSON: %s", err)
|
||||
|
||||
Reference in New Issue
Block a user