|
|
|
@ -11,6 +11,8 @@ import ( |
|
|
|
|
const ( |
|
|
|
|
TestToken = "153667468:AAHlSHlMqSt1f_uFmVRJbm5gntu2HI4WW8I" |
|
|
|
|
ChatID = 76918703 |
|
|
|
|
ChannelBot = "903278594:AAHmLoQncKOMKz2A644-cIK1Sb0VwfnOpGQ" |
|
|
|
|
Channel = "@nightghost_test" |
|
|
|
|
SupergroupChatID = -1001120141283 |
|
|
|
|
ReplyToMessageID = 35 |
|
|
|
|
ExistingPhotoFileID = "AgADAgADw6cxG4zHKAkr42N7RwEN3IFShCoABHQwXEtVks4EH2wBAAEC" |
|
|
|
@ -153,6 +155,51 @@ func TestSendWithNewPhotoReply(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestSendNewPhotoToChannel(t *testing.T) { |
|
|
|
|
bot, _ := NewBotAPI(ChannelBot) |
|
|
|
|
|
|
|
|
|
msg := NewPhotoUploadToChannel(Channel, "tests/image.jpg") |
|
|
|
|
msg.Caption = "Test" |
|
|
|
|
_, err := bot.Send(msg) |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
t.Error(err) |
|
|
|
|
t.Fail() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestSendNewPhotoToChannelFileBytes(t *testing.T) { |
|
|
|
|
bot, _ := NewBotAPI(ChannelBot) |
|
|
|
|
|
|
|
|
|
data, _ := ioutil.ReadFile("tests/image.jpg") |
|
|
|
|
b := FileBytes{Name: "image.jpg", Bytes: data} |
|
|
|
|
|
|
|
|
|
msg := NewPhotoUploadToChannel(Channel, b) |
|
|
|
|
msg.Caption = "Test" |
|
|
|
|
_, err := bot.Send(msg) |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
t.Error(err) |
|
|
|
|
t.Fail() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestSendNewPhotoToChannelFileReader(t *testing.T) { |
|
|
|
|
bot, _ := NewBotAPI(ChannelBot) |
|
|
|
|
|
|
|
|
|
f, _ := os.Open("tests/image.jpg") |
|
|
|
|
reader := FileReader{Name: "image.jpg", Reader: f, Size: -1} |
|
|
|
|
|
|
|
|
|
msg := NewPhotoUploadToChannel(Channel, reader) |
|
|
|
|
msg.Caption = "Test" |
|
|
|
|
_, err := bot.Send(msg) |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
t.Error(err) |
|
|
|
|
t.Fail() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestSendWithExistingPhoto(t *testing.T) { |
|
|
|
|
bot, _ := getBot(t) |
|
|
|
|
|
|
|
|
|