You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
telebot/telebot_test.go

38 lines
625 B
Go

package telebot
import (
"log"
"testing"
"time"
)
const TESTING_TOKEN = "107177593:AAHBJfF3nv3pZXVjXpoowVhv_KSGw56s8zo"
func TestCreate(t *testing.T) {
_, err := Create(TESTING_TOKEN)
if err != nil {
t.Fatal(err)
}
}
func TestListen(t *testing.T) {
if testing.Short() {
t.Skip("Skipping test in short mode.")
}
bot, err := Create(TESTING_TOKEN)
if err != nil {
t.Fatal(err)
}
bot.AddListener(func(bot *Bot, message Message) {
if message.Text == "/hi" {
bot.SendMessage(message.Chat,
"Hello, "+message.Sender.FirstName+"!")
}
})
log.Println("Listening...")
bot.Listen(1 * time.Second)
}