aboutsummaryrefslogtreecommitdiff
path: root/telegram/utils_test.go
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-03-09 22:15:56 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-03-09 22:15:56 +0300
commit699d75552abf35b243e9f589b24c7d880a8c7423 (patch)
tree2d2ab7a5082fcd7235504dc74170c14b0bb2cc84 /telegram/utils_test.go
parent4307f85a048e7f6783f112b9f243588e305a16fc (diff)
Move downloaded files to a permanent location
Diffstat (limited to 'telegram/utils_test.go')
-rw-r--r--telegram/utils_test.go140
1 files changed, 2 insertions, 138 deletions
diff --git a/telegram/utils_test.go b/telegram/utils_test.go
index a435ea9..5caf2c5 100644
--- a/telegram/utils_test.go
+++ b/telegram/utils_test.go
@@ -146,8 +146,8 @@ func TestFormatContent(t *testing.T) {
},
}
- content := c.formatContent(&file, "a.jpg")
- if content != "a.jpg (23 kbytes) | localhvost/b0896d9e9f1de7d2af59b080c3f0947b838c5c6c64f71c68a4b690a15de2ccf8.jpg" {
+ content := c.formatFile(&file)
+ if content != ". (23 kbytes) | " {
t.Errorf("Wrong file label: %v", content)
}
}
@@ -351,142 +351,6 @@ func TestMessageUnknown(t *testing.T) {
}
}
-func TestContentToFilenameSticker(t *testing.T) {
- sticker := client.MessageSticker{
- Sticker: &client.Sticker{},
- }
- _, filename := (&Client{}).contentToFilename(&sticker)
- if filename != "sticker.webp" {
- t.Errorf("Wrong sticker filename")
- }
-}
-
-func TestContentToFilenameVoice(t *testing.T) {
- voice := client.MessageVoiceNote{
- VoiceNote: &client.VoiceNote{
- Duration: 56,
- },
- }
- _, filename := (&Client{}).contentToFilename(&voice)
- if filename != "voice note (56 s.).oga" {
- t.Errorf("Wrong voice note filename")
- }
-}
-
-func TestContentToFilenameVideoNote(t *testing.T) {
- video := client.MessageVideoNote{
- VideoNote: &client.VideoNote{
- Duration: 56,
- },
- }
- _, filename := (&Client{}).contentToFilename(&video)
- if filename != "video note (56 s.).mp4" {
- t.Errorf("Wrong video note filename")
- }
-}
-
-func TestContentToFilenameAnimation(t *testing.T) {
- animation := client.MessageAnimation{
- Animation: &client.Animation{},
- }
- _, filename := (&Client{}).contentToFilename(&animation)
- if filename != "animation.mp4" {
- t.Errorf("Wrong animation filename")
- }
-}
-
-func TestContentToFilenamePhoto(t *testing.T) {
- photo := client.MessagePhoto{
- Photo: &client.Photo{
- Sizes: []*client.PhotoSize{
- &client.PhotoSize{
- Photo: &client.File{},
- },
- &client.PhotoSize{
- Photo: &client.File{
- Id: 56,
- },
- },
- },
- },
- }
- _, filename := (&Client{}).contentToFilename(&photo)
- if filename != "56.jpg" {
- t.Errorf("Wrong photo filename")
- }
-}
-
-func TestContentToFilenamePhotoNoSizes(t *testing.T) {
- photo := client.MessagePhoto{
- Photo: &client.Photo{
- Sizes: []*client.PhotoSize{},
- },
- }
- _, filename := (&Client{}).contentToFilename(&photo)
- if filename != "" {
- t.Errorf("Wrong filename of sizeless photo")
- }
-}
-
-func TestContentToFilenameAudio(t *testing.T) {
- audio := client.MessageAudio{
- Audio: &client.Audio{
- FileName: "swine.mp3",
- Audio: &client.File{
- Local: &client.LocalFile{
- Path: "C:/WINNT/swine.mp3",
- },
- },
- },
- }
- _, filename := (&Client{}).contentToFilename(&audio)
- if filename != "swine.mp3" {
- t.Errorf("Not oinking, shame on you!")
- }
-}
-
-func TestContentToFilenameVideo(t *testing.T) {
- video := client.MessageVideo{
- Video: &client.Video{
- FileName: "swine.3gp",
- Video: &client.File{
- Local: &client.LocalFile{
- Path: "C:/Document and Settings/Svinarchuk-PC/swine.3gp",
- },
- },
- },
- }
- _, filename := (&Client{}).contentToFilename(&video)
- if filename != "swine.3gp" {
- t.Errorf("Not pigdancing, shame on you!")
- }
-}
-
-func TestContentToFilenameDocument(t *testing.T) {
- document := client.MessageDocument{
- Document: &client.Document{
- FileName: "swine.doc",
- Document: &client.File{
- Local: &client.LocalFile{
- Path: "D:/My Documents/swine.doc",
- },
- },
- },
- }
- _, filename := (&Client{}).contentToFilename(&document)
- if filename != "swine.doc" {
- t.Errorf("Not hoofstomping, shame on you!")
- }
-}
-
-func TestContentToFilenameUnknown(t *testing.T) {
- unknown := client.MessageExpiredPhoto{}
- _, filename := (&Client{}).contentToFilename(&unknown)
- if filename != "" {
- t.Errorf("Wrong filename of unknown content")
- }
-}
-
func TestMessageToPrefix1(t *testing.T) {
message := client.Message{
Id: 42,