sse
sse copied to clipboard
Unit tests failing in a clean environment.
Running inside the official golang:1.6 Docker image, using stretchr/testify revision 1f4a1643a57e (on master), the unit tests are failing:
docker run -it --rm golang:1.6
$ /go# go get github.com/manucorporat/sse
$ /go# go get github.com/stretchr/testify/assert
$ /go# cd src/github.com/manucorporat/sse
$ /go/src/github.com/manucorporat/sse# go test .
--- FAIL: TestEncodeOnlyData (0.00s)
Error Trace: sse_test.go:31
Error: Not equal: []sse.Event{sse.Event{Event:"message", Id:"", Retry:0x0, Data:"junk\n\njk\nid:fake"}} (expected)
!= []sse.Event{sse.Event{Event:"", Id:"", Retry:0x0, Data:"junk\n\njk\nid:fake"}} (actual)
Diff:
--- Expected
+++ Actual
@@ -2,3 +2,3 @@
(sse.Event) {
- Event: (string) (len=7) "message",
+ Event: (string) "",
Id: (string) "",
--- FAIL: TestEncodeWithEvent (0.00s)
Error Trace: sse_test.go:52
Error: Not equal: []sse.Event{sse.Event{Event:"t\\n:<>\\r\test", Id:"", Retry:0x0, Data:"junk\n\njk\nid:fake"}} (expected)
!= []sse.Event{sse.Event{Event:"t\n:<>\r\test", Id:"", Retry:0x0, Data:"junk\n\njk\nid:fake"}} (actual)
Diff:
--- Expected
+++ Actual
@@ -2,3 +2,3 @@
(sse.Event) {
- Event: (string) (len=12) "t\\n:<>\\r\test",
+ Event: (string) (len=10) "t\n:<>\r\test",
Id: (string) "",
FAIL
FAIL github.com/manucorporat/sse 0.003s
I can confirm this issue still exists. Is this an issue with the tests or an actual problem?
this issue still exists, my 2¢:
TestEncodeOnlyData
This is an issue with test. The event type will be set to message
if it's empty, which complies with the spec.
TestEncodeWithEvent
This is an actual decoder problem. CRLF/CR/LF are all line ending signal. If t\n:<>\r\test
appeared after event:
, it should be parsed into those tokens:
-
event:t
: event type wast
-
\n
: event type line ends -
:<>
: ignored -
\r
: ignored line ends -
\test
: "using the whole line as the field name, and the empty string as the field value." (ref)