databag/net/server/internal/status_test.go

27 lines
510 B
Go
Raw Normal View History

2022-01-19 19:36:53 +00:00
package databag
import (
"net/url"
"net/http"
"net/http/httptest"
2022-01-19 20:07:57 +00:00
"github.com/gorilla/websocket"
2022-01-19 19:36:53 +00:00
)
type StatusHandler struct {}
func (h *StatusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
Status(w, r)
}
2022-01-19 20:07:57 +00:00
func getTestWebsocket() *websocket.Conn {
2022-01-19 19:36:53 +00:00
h := StatusHandler{}
s := httptest.NewServer(&h)
wsUrl, _ := url.Parse(s.URL)
wsUrl.Scheme = "ws"
2022-01-19 20:07:57 +00:00
ws, _, err := websocket.DefaultDialer.Dial(wsUrl.String(), nil)
if err != nil {
PrintMsg(err.Error());
}
return ws
2022-01-19 19:36:53 +00:00
}