2015-11-21 11:17:34 +01:00
|
|
|
package tgbotapi_test
|
|
|
|
|
|
|
|
import (
|
2015-12-13 18:00:20 +01:00
|
|
|
"github.com/zhulik/telegram-bot-api"
|
2015-11-21 11:17:34 +01:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestUserStringWith(t *testing.T) {
|
|
|
|
user := tgbotapi.User{0, "Test", "Test", ""}
|
|
|
|
|
|
|
|
if user.String() != "Test Test" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestUserStringWithUserName(t *testing.T) {
|
|
|
|
user := tgbotapi.User{0, "Test", "Test", "@test"}
|
|
|
|
|
|
|
|
if user.String() != "@test" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMessageTime(t *testing.T) {
|
|
|
|
message := tgbotapi.Message{Date: 0}
|
|
|
|
|
|
|
|
date := time.Unix(0, 0)
|
|
|
|
if message.Time() != date {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestChatIsPrivate(t *testing.T) {
|
|
|
|
chat := tgbotapi.Chat{ID: 10, Type: "private"}
|
|
|
|
|
|
|
|
if chat.IsPrivate() != true {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestChatIsGroup(t *testing.T) {
|
|
|
|
chat := tgbotapi.Chat{ID: 10, Type: "group"}
|
|
|
|
|
|
|
|
if chat.IsGroup() != true {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestChatIsChannel(t *testing.T) {
|
|
|
|
chat := tgbotapi.Chat{ID: 10, Type: "channel"}
|
|
|
|
|
|
|
|
if chat.IsChannel() != true {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-10 03:13:31 +01:00
|
|
|
func TestChatIsSuperGroup(t *testing.T) {
|
|
|
|
chat := tgbotapi.Chat{ID: 10, Type: "supergroup"}
|
|
|
|
|
|
|
|
if !chat.IsSuperGroup() {
|
|
|
|
t.Fail()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-21 11:17:34 +01:00
|
|
|
func TestFileLink(t *testing.T) {
|
|
|
|
file := tgbotapi.File{FilePath: "test/test.txt"}
|
|
|
|
|
|
|
|
if file.Link("token") != "https://api.telegram.org/file/bottoken/test/test.txt" {
|
|
|
|
t.Fail()
|
|
|
|
}
|
2015-11-21 12:22:08 +01:00
|
|
|
}
|