1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2024-09-17 15:38:46 +00:00
arikawa/api/integration_test.go
diamondburned b8994ed0da Voice: Remove state-keeping of sessions
This commit gets rid of all the code that previously managed different
voice sessions in different guilds. This is because there is rarely ever
a need for this, and most bots that need this could do their own
keeping.

This change, although removes some features off of the package, adds a
lot of clarity on what to do exactly when it comes to connecting to a
voice channel.

In order to make the migration process a bit easier, an example has been
added which guides through using the voice.Session API.
2020-11-30 19:12:20 -08:00

83 lines
1.4 KiB
Go

// +build !unitonly
package api
import (
"fmt"
"log"
"testing"
"time"
"github.com/diamondburned/arikawa/v2/internal/testenv"
)
func TestIntegration(t *testing.T) {
cfg := testenv.Must(t)
client := NewClient("Bot " + cfg.BotToken)
// Simple GET request
u, err := client.Me()
if err != nil {
t.Fatal("Can't get self:", err)
}
log.Println("API user:", u.Username)
// POST with URL param and paginator
_, err = client.Guilds(100)
if err != nil {
t.Fatal("Can't get guilds:", err)
}
}
var emojisToSend = [...]string{
"🥺",
"❤",
"😂",
"🥰",
"😊",
"🔥",
"✔",
"👍",
"😍",
"🐻",
"🤯",
"🔣",
"🍔",
"🎌",
"🇯🇵",
"🎥",
"🇺🇸",
"🌎",
}
func TestReactions(t *testing.T) {
cfg := testenv.Must(t)
client := NewClient("Bot " + cfg.BotToken)
msg := fmt.Sprintf("This is a message sent at %v.", time.Now())
// Send a new message.
m, err := client.SendMessage(cfg.ChannelID, msg, nil)
if err != nil {
t.Fatal("Failed to send message:", err)
}
now := time.Now()
for _, emojiString := range emojisToSend {
if err := client.React(cfg.ChannelID, m.ID, emojiString); err != nil {
t.Fatal("Failed to send emoji "+emojiString+":", err)
}
}
msg += fmt.Sprintf(" Total time taken to send all reactions: %v.", time.Now().Sub(now))
m, err = client.EditMessage(cfg.ChannelID, m.ID, msg, nil, false)
if err != nil {
t.Fatal("Failed to edit message:", err)
}
}