mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-09-16 10:06:54 +00:00
Fix tests without skipping
This commit is contained in:
parent
5dc54bbd2e
commit
532cd0e2ce
2 changed files with 16 additions and 10 deletions
|
@ -88,12 +88,14 @@ func SetupServerAndHandle(config *ConfigFile, serveMux *http.ServeMux) {
|
||||||
go ircConnection()
|
go ircConnection()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TwitchDotTv = "http://www.twitch.tv"
|
||||||
|
|
||||||
// SocketUpgrader is the websocket.Upgrader currently in use.
|
// SocketUpgrader is the websocket.Upgrader currently in use.
|
||||||
var SocketUpgrader = websocket.Upgrader{
|
var SocketUpgrader = websocket.Upgrader{
|
||||||
ReadBufferSize: 1024,
|
ReadBufferSize: 1024,
|
||||||
WriteBufferSize: 1024,
|
WriteBufferSize: 1024,
|
||||||
CheckOrigin: func(r *http.Request) bool {
|
CheckOrigin: func(r *http.Request) bool {
|
||||||
return r.Header.Get("Origin") == "http://www.twitch.tv"
|
return r.Header.Get("Origin") == TwitchDotTv
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,8 +128,8 @@ func TGetUrls(testserver *httptest.Server) TURLs {
|
||||||
return TURLs{
|
return TURLs{
|
||||||
Websocket: fmt.Sprintf("ws://%s/", addr),
|
Websocket: fmt.Sprintf("ws://%s/", addr),
|
||||||
Origin: fmt.Sprintf("http://%s", addr),
|
Origin: fmt.Sprintf("http://%s", addr),
|
||||||
PubMsg: fmt.Sprintf("http://%s/pub_msg", addr),
|
PubMsg: fmt.Sprintf("http://%s/uncached_pub", addr),
|
||||||
SavePubMsg: fmt.Sprintf("http://%s/update_and_pub", addr),
|
SavePubMsg: fmt.Sprintf("http://%s/cached_pub", addr),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +204,9 @@ func TestSubscriptionAndPublish(t *testing.T) {
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
var headers http.Header = make(http.Header)
|
||||||
|
headers.Set("Origin", TwitchDotTv)
|
||||||
|
|
||||||
// client 1: sub ch1, ch2
|
// client 1: sub ch1, ch2
|
||||||
// client 2: sub ch1, ch3
|
// client 2: sub ch1, ch3
|
||||||
// client 3: sub none
|
// client 3: sub none
|
||||||
|
@ -213,10 +216,8 @@ func TestSubscriptionAndPublish(t *testing.T) {
|
||||||
// msg 3: chEmpty
|
// msg 3: chEmpty
|
||||||
// msg 4: global
|
// msg 4: global
|
||||||
|
|
||||||
t.SkipNow()
|
|
||||||
|
|
||||||
// Client 1
|
// Client 1
|
||||||
conn, resp, err = websocket.DefaultDialer.Dial(urls.Websocket, http.Header{})
|
conn, resp, err = websocket.DefaultDialer.Dial(urls.Websocket, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -245,7 +246,7 @@ func TestSubscriptionAndPublish(t *testing.T) {
|
||||||
}(conn)
|
}(conn)
|
||||||
|
|
||||||
// Client 2
|
// Client 2
|
||||||
conn, resp, err = websocket.DefaultDialer.Dial(urls.Websocket, http.Header{})
|
conn, resp, err = websocket.DefaultDialer.Dial(urls.Websocket, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -274,7 +275,7 @@ func TestSubscriptionAndPublish(t *testing.T) {
|
||||||
}(conn)
|
}(conn)
|
||||||
|
|
||||||
// Client 3
|
// Client 3
|
||||||
conn, resp, err = websocket.DefaultDialer.Dial(urls.Websocket, http.Header{})
|
conn, resp, err = websocket.DefaultDialer.Dial(urls.Websocket, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -346,7 +347,7 @@ func TestSubscriptionAndPublish(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start client 4
|
// Start client 4
|
||||||
conn, resp, err = websocket.DefaultDialer.Dial(urls.Websocket, http.Header{})
|
conn, resp, err = websocket.DefaultDialer.Dial(urls.Websocket, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
return
|
return
|
||||||
|
@ -407,9 +408,12 @@ func BenchmarkUserSubscriptionSinglePublish(b *testing.B) {
|
||||||
TSetup(&server, &urls)
|
TSetup(&server, &urls)
|
||||||
defer unsubscribeAllClients()
|
defer unsubscribeAllClients()
|
||||||
|
|
||||||
|
var headers http.Header = make(http.Header)
|
||||||
|
headers.Set("Origin", TwitchDotTv)
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
conn, _, err := websocket.DefaultDialer.Dial(urls.Websocket, http.Header{})
|
conn, _, err := websocket.DefaultDialer.Dial(urls.Websocket, headers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Error(err)
|
b.Error(err)
|
||||||
break
|
break
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue