mirror of
https://github.com/diamondburned/arikawa.git
synced 2024-11-27 17:23:00 +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) {
|
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
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue