From bb333edf69cf0ce0df3bad6886b0c44509e00b24 Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Sun, 13 Jul 2025 06:13:45 -0400 Subject: [PATCH] Fix other tests --- persistence/sessions_test.go | 21 +++++++++++---------- telegram/loginwizard.go | 2 +- telegram/utils_test.go | 24 ++++++++++++++++++++---- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/persistence/sessions_test.go b/persistence/sessions_test.go index a8ec171..187445b 100644 --- a/persistence/sessions_test.go +++ b/persistence/sessions_test.go @@ -53,16 +53,17 @@ func TestSessionToMap(t *testing.T) { } m := session.ToMap() sample := map[string]string{ - "timezone": "klsf", - "keeponline": "false", - "muc": "true", - "rawmessages": "true", - "asciiarrows": "false", - "oobmode": "true", - "carbons": "false", - "hideids": "false", - "receipts": "true", - "nativeedits": "false", + "timezone": "klsf", + "keeponline": "false", + "muc": "true", + "rawmessages": "true", + "asciiarrows": "false", + "oobmode": "true", + "carbons": "false", + "hideids": "false", + "receipts": "true", + "nativeedits": "false", + "ignoregroupdeletions": "false", } if !reflect.DeepEqual(m, sample) { t.Errorf("Map does not match the sample: %v", m) diff --git a/telegram/loginwizard.go b/telegram/loginwizard.go index 0e5cc9e..296e748 100644 --- a/telegram/loginwizard.go +++ b/telegram/loginwizard.go @@ -74,7 +74,7 @@ func (c *Client) wizardStageOrPrompt(stage, message string) { log.Debugf("writing wizard stage %v", stage) c.loginWizard.nextStage <- stage } else { - log.Warn("Skipping stage %v, wizard cannot keep up", stage) + log.Warnf("Skipping stage %v, wizard cannot keep up", stage) } c.loginWizard.chanBusy = true c.locks.loginWizardWriteLock.Unlock() diff --git a/telegram/utils_test.go b/telegram/utils_test.go index e89077d..3fb9dc9 100644 --- a/telegram/utils_test.go +++ b/telegram/utils_test.go @@ -68,12 +68,28 @@ func TestFormatMessageOneline(t *testing.T) { }, } - text := (&Client{}).formatMessage(0, 0, true, &message) + text := (&Client{}).formatMessage(0, 0, true, true, &message) if text != "42 | | tist" { t.Errorf("Wrong oneline message formatting: %v", text) } } +func TestFormatMessageNoSender(t *testing.T) { + message := client.Message{ + Id: 42, + Content: &client.MessageText{ + Text: &client.FormattedText{ + Text: "tist", + }, + }, + } + + text := (&Client{}).formatMessage(0, 0, true, false, &message) + if text != "42 | tist" { + t.Errorf("Wrong nosender message formatting: %v", text) + } +} + func TestFormatMessageMultiline(t *testing.T) { message := client.Message{ Id: 42, @@ -84,7 +100,7 @@ func TestFormatMessageMultiline(t *testing.T) { }, } - text := (&Client{}).formatMessage(0, 0, true, &message) + text := (&Client{}).formatMessage(0, 0, true, true, &message) if text != "42 | | tist" { t.Errorf("Wrong multiline message formatting: %v", text) } @@ -104,7 +120,7 @@ func TestFormatMessageOnelinePreview(t *testing.T) { c := &Client{ Session: &persistence.Session{}, } - text := c.formatMessage(0, 0, false, &message) + text := c.formatMessage(0, 0, false, true, &message) if text != "42 | | 10 Jan 2008 21:20:00 | tist" { t.Errorf("Wrong oneline preview message formatting: %v", text) } @@ -124,7 +140,7 @@ func TestFormatMessageMultilinePreview(t *testing.T) { c := &Client{ Session: &persistence.Session{}, } - text := c.formatMessage(0, 0, false, &message) + text := c.formatMessage(0, 0, false, true, &message) if text != "42 | | 10 Jan 2008 21:20:00 | tist\nziz" { t.Errorf("Wrong multiline preview message formatting: %v", text) }