1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-27 09:12:53 +00:00

Compare commits

...

2 commits

Author SHA1 Message Date
diamondburned 8561e2bd51 Gateway: Potential fix for URL() 2021-04-02 21:55:39 -07:00
diamondburned 6c67d05e10 Gateway: Add URL test 2021-04-02 20:03:25 -07:00
2 changed files with 21 additions and 4 deletions

View file

@ -58,10 +58,12 @@ type SessionStartLimit struct {
func URL() (string, error) { func URL() (string, error) {
var g BotData var g BotData
return g.URL, httputil.NewClient().RequestJSON( c := httputil.NewClient()
&g, "GET", if err := c.RequestJSON(&g, "GET", EndpointGateway); err != nil {
EndpointGateway, return "", err
) }
return g.URL, nil
} }
// BotURL fetches the Gateway URL along with extra metadata. The token // BotURL fetches the Gateway URL along with extra metadata. The token

View file

@ -21,6 +21,21 @@ func init() {
} }
} }
func TestURL(t *testing.T) {
u, err := URL()
if err != nil {
t.Fatal("failed to get gateway URL:", err)
}
if u == "" {
t.Fatal("gateway URL is empty")
}
if !strings.HasPrefix(u, "wss://") {
t.Fatal("gatewayURL is invalid:", u)
}
}
func TestInvalidToken(t *testing.T) { func TestInvalidToken(t *testing.T) {
g, err := NewGateway("bad token") g, err := NewGateway("bad token")
if err != nil { if err != nil {