mirror of
https://github.com/hanzoskill/sogcli.git
synced 2026-10-30 21:03:29 +00:00
79 lines
1.5 KiB
Go
79 lines
1.5 KiB
Go
package imap
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestConfigDefaults(t *testing.T) {
|
|
cfg := Config{
|
|
Host: "imap.example.com",
|
|
Port: 993,
|
|
TLS: true,
|
|
Email: "[email protected]",
|
|
Password: "secret",
|
|
}
|
|
|
|
assert.Equal(t, "imap.example.com", cfg.Host)
|
|
assert.Equal(t, 993, cfg.Port)
|
|
assert.True(t, cfg.TLS)
|
|
assert.False(t, cfg.Insecure)
|
|
assert.False(t, cfg.NoTLS)
|
|
}
|
|
|
|
func TestConfigInsecure(t *testing.T) {
|
|
cfg := Config{
|
|
Host: "localhost",
|
|
Port: 3993,
|
|
TLS: true,
|
|
Insecure: true,
|
|
Email: "test@localhost",
|
|
}
|
|
|
|
assert.True(t, cfg.TLS)
|
|
assert.True(t, cfg.Insecure)
|
|
}
|
|
|
|
func TestConfigNoTLS(t *testing.T) {
|
|
cfg := Config{
|
|
Host: "localhost",
|
|
Port: 3143,
|
|
NoTLS: true,
|
|
Email: "test@localhost",
|
|
}
|
|
|
|
assert.True(t, cfg.NoTLS)
|
|
assert.False(t, cfg.TLS)
|
|
}
|
|
|
|
func TestMessageStruct(t *testing.T) {
|
|
msg := Message{
|
|
UID: 12345,
|
|
Subject: "Test Subject",
|
|
From: "[email protected]",
|
|
To: "[email protected]",
|
|
Date: "Jan 20",
|
|
Seen: true,
|
|
Body: "Hello, World!",
|
|
}
|
|
|
|
assert.Equal(t, uint32(12345), msg.UID)
|
|
assert.Equal(t, "Test Subject", msg.Subject)
|
|
assert.Equal(t, "[email protected]", msg.From)
|
|
assert.Equal(t, "[email protected]", msg.To)
|
|
assert.Equal(t, "Jan 20", msg.Date)
|
|
assert.True(t, msg.Seen)
|
|
assert.Equal(t, "Hello, World!", msg.Body)
|
|
}
|
|
|
|
func TestMessageUnread(t *testing.T) {
|
|
msg := Message{
|
|
UID: 1,
|
|
Subject: "Unread message",
|
|
Seen: false,
|
|
}
|
|
|
|
assert.False(t, msg.Seen)
|
|
}
|