Fix other tests

This commit is contained in:
Bohdan Horbeshko 2025-07-13 06:13:45 -04:00
parent 24086e903f
commit bb333edf69
3 changed files with 32 additions and 15 deletions

View file

@ -53,16 +53,17 @@ func TestSessionToMap(t *testing.T) {
} }
m := session.ToMap() m := session.ToMap()
sample := map[string]string{ sample := map[string]string{
"timezone": "klsf", "timezone": "klsf",
"keeponline": "false", "keeponline": "false",
"muc": "true", "muc": "true",
"rawmessages": "true", "rawmessages": "true",
"asciiarrows": "false", "asciiarrows": "false",
"oobmode": "true", "oobmode": "true",
"carbons": "false", "carbons": "false",
"hideids": "false", "hideids": "false",
"receipts": "true", "receipts": "true",
"nativeedits": "false", "nativeedits": "false",
"ignoregroupdeletions": "false",
} }
if !reflect.DeepEqual(m, sample) { if !reflect.DeepEqual(m, sample) {
t.Errorf("Map does not match the sample: %v", m) t.Errorf("Map does not match the sample: %v", m)

View file

@ -74,7 +74,7 @@ func (c *Client) wizardStageOrPrompt(stage, message string) {
log.Debugf("writing wizard stage %v", stage) log.Debugf("writing wizard stage %v", stage)
c.loginWizard.nextStage <- stage c.loginWizard.nextStage <- stage
} else { } 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.loginWizard.chanBusy = true
c.locks.loginWizardWriteLock.Unlock() c.locks.loginWizardWriteLock.Unlock()

View file

@ -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" { if text != "42 | | tist" {
t.Errorf("Wrong oneline message formatting: %v", text) 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) { func TestFormatMessageMultiline(t *testing.T) {
message := client.Message{ message := client.Message{
Id: 42, 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" { if text != "42 | | tist" {
t.Errorf("Wrong multiline message formatting: %v", text) t.Errorf("Wrong multiline message formatting: %v", text)
} }
@ -104,7 +120,7 @@ func TestFormatMessageOnelinePreview(t *testing.T) {
c := &Client{ c := &Client{
Session: &persistence.Session{}, 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" { if text != "42 | | 10 Jan 2008 21:20:00 | tist" {
t.Errorf("Wrong oneline preview message formatting: %v", text) t.Errorf("Wrong oneline preview message formatting: %v", text)
} }
@ -124,7 +140,7 @@ func TestFormatMessageMultilinePreview(t *testing.T) {
c := &Client{ c := &Client{
Session: &persistence.Session{}, 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" { if text != "42 | | 10 Jan 2008 21:20:00 | tist\nziz" {
t.Errorf("Wrong multiline preview message formatting: %v", text) t.Errorf("Wrong multiline preview message formatting: %v", text)
} }