sse icon indicating copy to clipboard operation
sse copied to clipboard

Unit tests failing in a clean environment.

Open kbalonek opened this issue 9 years ago • 2 comments

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

kbalonek avatar Feb 23 '16 17:02 kbalonek

I can confirm this issue still exists. Is this an issue with the tests or an actual problem?

satta avatar Jun 19 '17 16:06 satta

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 was t
  • \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)

ahxxm avatar Feb 03 '18 06:02 ahxxm