Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Forceu committed Jul 22, 2024
1 parent 4f71a2b commit 673f4b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/models/UploadStatus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ func TestUploadStatus_ToJson(t *testing.T) {
status := UploadStatus{}
output, err := status.ToJson()
test.IsNil(t, err)
test.IsEqualString(t, string(output), "{\"chunkid\":\"\",\"currentstatus\":0,\"type\":\"uploadstatus\"}")
test.IsEqualString(t, string(output), "{\"chunkid\":\"\",\"currentstatus\":0}")
}
9 changes: 5 additions & 4 deletions internal/webserver/sse/Sse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func TestPublishNewStatus(t *testing.T) {

go PublishNewStatus("test_status")
receivedStatus := <-replyChannel
test.IsEqualString(t, receivedStatus, "test_status")
test.IsEqualString(t, receivedStatus, "event: message\ndata: test_status\n\n")
removeListener("test_status")
}

Expand Down Expand Up @@ -89,18 +89,19 @@ func TestGetStatusSSE(t *testing.T) {
body, err := io.ReadAll(rr.Body)
test.IsNil(t, err)

test.IsEqualString(t, string(body), "{\"chunkid\":\"validstatus_0\",\"currentstatus\":0,\"type\":\"uploadstatus\"}\n{\"chunkid\":\"validstatus_1\",\"currentstatus\":1,\"type\":\"uploadstatus\"}\n")
test.IsEqualString(t, string(body), "event: message\ndata: {\"chunkid\":\"validstatus_0\",\"currentstatus\":0}\n\n"+
"event: message\ndata: {\"chunkid\":\"validstatus_1\",\"currentstatus\":1}\n\n")

// Test ping message
time.Sleep(3 * time.Second)
body, err = io.ReadAll(rr.Body)
test.IsNil(t, err)
test.IsEqualString(t, string(body), "{\"type\":\"ping\"}\n")
test.IsEqualString(t, string(body), "event: ping\n\n")

PublishNewStatus("testcontent")
time.Sleep(1 * time.Second)
body, err = io.ReadAll(rr.Body)
test.IsNil(t, err)
test.IsEqualString(t, string(body), "testcontent")
test.IsEqualString(t, string(body), "event: message\ndata: testcontent\n\n")
Shutdown()
}

0 comments on commit 673f4b3

Please sign in to comment.