-
Notifications
You must be signed in to change notification settings - Fork 1
/
channel_test.go
61 lines (47 loc) · 1.21 KB
/
channel_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package rest
import (
"context"
"os"
"strconv"
"testing"
"github.com/stretchr/testify/require"
"wumpgo.dev/wumpgo/objects"
)
func getRealClient(t *testing.T) RESTClient {
tokenEnv := os.Getenv("TOKEN")
if tokenEnv == "" {
t.Skip("TOKEN env var must be set to run tests against discord API")
}
if testing.Short() {
t.Skip("Test skipped due to short mode")
}
return New(
WithToken(objects.TokenTypeBot, tokenEnv),
WithRateLimiter(NewLeakyBucketRatelimiter()),
)
}
func testChannelSnowflake(t *testing.T) objects.Snowflake {
env := os.Getenv("TEST_CHANNEL_ID")
if env != "" {
i, err := strconv.Atoi(env)
require.NoError(t, err)
return objects.Snowflake(i)
}
return objects.Snowflake(484093378993192971)
}
func TestClient_GetChannel_Integration(t *testing.T) {
client := getRealClient(t)
c, err := client.GetChannel(context.Background(), testChannelSnowflake(t))
if err != nil {
t.Error("failed to get channel:", err)
}
t.Log(c)
}
func TestClient_GetChannelMessages_Integration(t *testing.T) {
client := getRealClient(t)
c, err := client.GetChannelMessages(context.Background(), testChannelSnowflake(t), nil)
if err != nil {
t.Error("failed to get channel messages:", err)
}
t.Log(c)
}