forked from googollee/go-engine.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server_test.go
39 lines (33 loc) · 951 Bytes
/
server_test.go
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
32
33
34
35
36
37
38
39
package engineio
import (
"net/http"
"testing"
"time"
. "github.com/smartystreets/goconvey/convey"
)
func TestServer(t *testing.T) {
Convey("Setup server", t, func() {
server, err := NewServer(nil)
So(err, ShouldBeNil)
server.SetPingInterval(time.Second)
So(server.config.PingInterval, ShouldEqual, time.Second)
server.SetPingTimeout(10 * time.Second)
So(server.config.PingTimeout, ShouldEqual, 10*time.Second)
f := func(*http.Request) error { return nil }
server.SetAllowRequest(f)
So(server.config.AllowRequest, ShouldEqual, f)
server.SetAllowUpgrades(false)
So(server.config.AllowUpgrades, ShouldBeFalse)
server.SetCookie("prefix")
So(server.config.Cookie, ShouldEqual, "prefix")
})
Convey("Create server", t, func() {
Convey("Test new id", func() {
req, err := http.NewRequest("GET", "/", nil)
So(err, ShouldBeNil)
id1 := newId(req)
id2 := newId(req)
So(id1, ShouldNotEqual, id2)
})
})
}