-
-
Notifications
You must be signed in to change notification settings - Fork 341
Expand file tree
/
Copy pathevent_test.go
More file actions
31 lines (20 loc) · 656 Bytes
/
event_test.go
File metadata and controls
31 lines (20 loc) · 656 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package mercure
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestEncodeFull(t *testing.T) {
t.Parallel()
e := &Event{"several\nlines\rwith\r\neol", "custom-id", "type", 5}
assert.Equal(t, "event: type\nretry: 5\nid: custom-id\ndata: several\ndata: lines\ndata: with\ndata: eol\n\n", e.String())
}
func TestEncodeNoType(t *testing.T) {
t.Parallel()
e := &Event{"data", "custom-id", "", 5}
assert.Equal(t, "retry: 5\nid: custom-id\ndata: data\n\n", e.String())
}
func TestEncodeNoRetry(t *testing.T) {
t.Parallel()
e := &Event{"data", "custom-id", "", 0}
assert.Equal(t, "id: custom-id\ndata: data\n\n", e.String())
}