mirror of https://github.com/tucnak/telebot
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.
45 lines
913 B
Go
45 lines
913 B
Go
package telebot
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestTelebot(t *testing.T) {
|
|
token := os.Getenv("TELEBOT_SECRET")
|
|
if token == "" {
|
|
fmt.Println("ERROR: " +
|
|
"In order to test telebot functionality, you need to set up " +
|
|
"TELEBOT_SECRET environmental variable, which represents an API " +
|
|
"key to a Telegram bot.\n")
|
|
t.Fatal("Could't find TELEBOT_SECRET, aborting.")
|
|
}
|
|
|
|
_, err := NewBot(token)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
// TODO: Uncomment when Telegram fixes behavior for self-messaging
|
|
|
|
/*messages := make(chan Message)
|
|
|
|
intelligence := "welcome to the jungle"
|
|
|
|
bot.SendMessage(bot.Identity, intelligence)
|
|
bot.Listen(messages, 1*time.Second)
|
|
|
|
select {
|
|
case message := <-messages:
|
|
{
|
|
if message.Text != intelligence {
|
|
t.Error("Self-handshake failed.")
|
|
}
|
|
}
|
|
|
|
case <-time.After(5 * time.Second):
|
|
t.Error("Self-handshake test took too long, aborting.")
|
|
}*/
|
|
}
|