telebot/telebot_test.go

48 lines
935 B
Go
Raw Normal View History

2015-06-25 19:32:41 +00:00
package telebot
import (
2015-06-27 11:30:35 +00:00
"fmt"
"os"
"testing"
)
2015-06-25 19:32:41 +00:00
2015-07-06 16:58:54 +00:00
func TestBot(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
2015-06-27 11:30:35 +00:00
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.")
}
2017-11-21 02:28:39 +00:00
_, err := NewBot(Settings{Token: token})
2015-07-06 16:58:54 +00:00
if err != nil {
t.Fatal("couldn't create bot:", err)
2015-07-06 16:58:54 +00:00
}
}
func TestRecipient(_ *testing.T) {
bot := Bot{}
bot.Send(&User{}, "")
bot.Send(&Chat{}, "")
}
2015-07-06 16:58:54 +00:00
func TestFile(t *testing.T) {
file := FromDisk("telebot.go")
if file.InCloud() {
2015-07-06 16:58:54 +00:00
t.Fatal("Newly created file can't exist on Telegram servers!")
}
2015-07-06 16:58:54 +00:00
file.FileID = "magic"
if file.FileLocal != "telebot.go" {
2015-07-06 16:58:54 +00:00
t.Fatal("File doesn't preserve its original filename.")
}
}