Merge branch 'fix-tests'

This commit is contained in:
Javier Provecho Fernandez 2015-09-25 12:14:45 +02:00
commit 52fcc5dbf6
2 changed files with 4 additions and 9 deletions

View File

@ -7,11 +7,11 @@ package gin
import (
"bytes"
"errors"
"fmt"
"html/template"
"mime/multipart"
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"
@ -352,7 +352,7 @@ func TestContextRenderSSE(t *testing.T) {
"bar": "foo",
})
assert.Equal(t, fmt.Sprintf("%v", w.Body), "event:float\ndata:1.5\n\nid:123\ndata:text\n\nevent:chat\ndata:{\"bar\":\"foo\",\"foo\":\"bar\"}\n\n")
assert.Equal(t, strings.Replace(w.Body.String(), " ", "", -1), strings.Replace("event:float\ndata:1.5\n\nid:123\ndata:text\n\nevent:chat\ndata:{\"bar\":\"foo\",\"foo\":\"bar\"}\n\n", " ", "", -1))
}
func TestContextRenderFile(t *testing.T) {

View File

@ -6,6 +6,7 @@ package gin
import (
"errors"
"strings"
"testing"
@ -245,11 +246,5 @@ func TestMiddlewareWrite(t *testing.T) {
w := performRequest(router, "GET", "/")
assert.Equal(t, w.Code, 400)
assert.Equal(t, w.Body.String(), `hola
<map><foo>bar</foo></map>{"foo":"bar"}
{"foo":"bar"}
event:test
data:message
`)
assert.Equal(t, strings.Replace(w.Body.String(), " ", "", -1), strings.Replace("hola\n<map><foo>bar</foo></map>{\"foo\":\"bar\"}\n{\"foo\":\"bar\"}\nevent:test\ndata:message\n\n", " ", "", -1))
}