1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-11-30 10:43:30 +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) {
var g BotData
return g.URL, httputil.NewClient().RequestJSON(
&g, "GET",
EndpointGateway,
)
c := httputil.NewClient()
if err := c.RequestJSON(&g, "GET", EndpointGateway); err != nil {
return "", err
}
return g.URL, nil
}
// 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) {
g, err := NewGateway("bad token")
if err != nil {