This repository was archived by the owner on Aug 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtransport_test.go
More file actions
36 lines (31 loc) · 1.33 KB
/
transport_test.go
File metadata and controls
36 lines (31 loc) · 1.33 KB
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
package wray
import (
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestSelectTransport(t *testing.T) {
Convey("when all transports are usable", t, func(){
var transportTypes []string
var transport Transport
var fakeHttpTransport *FakeHttpTransport
var fayeClient *FayeClient
Given(func(){ transportTypes = []string{"long-polling"} })
Given(func(){ fakeHttpTransport = &FakeHttpTransport{usable: true} })
Given(func(){ fayeClient = &FayeClient{url: "http://localhost"} })
Given(func(){ registeredTransports = []Transport{fakeHttpTransport} })
When(func(){ transport, _ = SelectTransport(fayeClient, transportTypes, []string{}) })
Then(func(){ So(transport, ShouldEqual, fakeHttpTransport) })
})
Convey("when no transports are usable", t, func(){
var transportTypes []string
var fakeHttpTransport *FakeHttpTransport
var fayeClient *FayeClient
var err error
Given(func(){ transportTypes = []string{"long-polling"} })
Given(func(){ fakeHttpTransport = &FakeHttpTransport{usable: false} })
Given(func(){ fayeClient = &FayeClient{url: "http://localhost"} })
Given(func(){ registeredTransports = []Transport{fakeHttpTransport} })
When(func(){ _, err = SelectTransport(fayeClient, transportTypes, []string{}) })
Then(func(){ So(err, ShouldNotBeNil) })
})
}