mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-30 10:43:30 +00:00
Compare commits
2 commits
8e02b1652c
...
8561e2bd51
Author | SHA1 | Date | |
---|---|---|---|
diamondburned | 8561e2bd51 | ||
diamondburned | 6c67d05e10 |
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue