aboutsummaryrefslogtreecommitdiff
path: root/telegram/utils_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'telegram/utils_test.go')
-rw-r--r--telegram/utils_test.go62
1 files changed, 57 insertions, 5 deletions
diff --git a/telegram/utils_test.go b/telegram/utils_test.go
index bfd6c49..03ab8bd 100644
--- a/telegram/utils_test.go
+++ b/telegram/utils_test.go
@@ -389,7 +389,7 @@ func TestMessageToPrefix1(t *testing.T) {
},
},
}
- prefix := (&Client{Session: &persistence.Session{}}).messageToPrefix(&message, "", "")
+ prefix := (&Client{Session: &persistence.Session{}}).messageToPrefix(&message, "", "", nil)
if prefix != "➡ 42 | fwd: ziz" {
t.Errorf("Wrong prefix: %v", prefix)
}
@@ -404,7 +404,7 @@ func TestMessageToPrefix2(t *testing.T) {
},
},
}
- prefix := (&Client{Session: &persistence.Session{}}).messageToPrefix(&message, "y.jpg", "")
+ prefix := (&Client{Session: &persistence.Session{}}).messageToPrefix(&message, "y.jpg", "", nil)
if prefix != "⬅ 56 | fwd: (zaz) | preview: y.jpg" {
t.Errorf("Wrong prefix: %v", prefix)
}
@@ -419,7 +419,7 @@ func TestMessageToPrefix3(t *testing.T) {
},
},
}
- prefix := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "a.jpg")
+ prefix := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "a.jpg", nil)
if prefix != "< 56 | fwd: (zuz) | file: a.jpg" {
t.Errorf("Wrong prefix: %v", prefix)
}
@@ -430,7 +430,7 @@ func TestMessageToPrefix4(t *testing.T) {
Id: 23,
IsOutgoing: true,
}
- prefix := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "")
+ prefix := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "", nil)
if prefix != "> 23" {
t.Errorf("Wrong prefix: %v", prefix)
}
@@ -445,8 +445,60 @@ func TestMessageToPrefix5(t *testing.T) {
},
},
}
- prefix := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "h.jpg", "a.jpg")
+ prefix := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "h.jpg", "a.jpg", nil)
if prefix != "< 560 | fwd: (zyz) | preview: h.jpg | file: a.jpg" {
t.Errorf("Wrong prefix: %v", prefix)
}
}
+
+func TestMessageToPrefix6(t *testing.T) {
+ message := client.Message{
+ Id: 23,
+ IsOutgoing: true,
+ ReplyToMessageId: 42,
+ }
+ reply := client.Message{
+ Id: 42,
+ Content: &client.MessageText{
+ Text: &client.FormattedText{
+ Text: "tist",
+ },
+ },
+ }
+ prefix := (&Client{Session: &persistence.Session{AsciiArrows: true}}).messageToPrefix(&message, "", "", &reply)
+ if prefix != "> 23 | reply: 42 | | tist" {
+ t.Errorf("Wrong prefix: %v", prefix)
+ }
+}
+
+func GetSenderIdEmpty(t *testing.T) {
+ message := client.Message{}
+ senderId := (&Client{}).getSenderId(&message)
+ if senderId != 0 {
+ t.Errorf("Wrong sender id: %v", senderId)
+ }
+}
+
+func GetSenderIdUser(t *testing.T) {
+ message := client.Message{
+ SenderId: &client.MessageSenderUser{
+ UserId: 42,
+ },
+ }
+ senderId := (&Client{}).getSenderId(&message)
+ if senderId != 42 {
+ t.Errorf("Wrong sender id: %v", senderId)
+ }
+}
+
+func GetSenderIdChat(t *testing.T) {
+ message := client.Message{
+ SenderId: &client.MessageSenderChat{
+ ChatId: -42,
+ },
+ }
+ senderId := (&Client{}).getSenderId(&message)
+ if senderId != -42 {
+ t.Errorf("Wrong sender id: %v", senderId)
+ }
+}