Implement internal mail skill MVP
This commit is contained in:
42
internal/config/config_test.go
Normal file
42
internal/config/config_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestLoadDefaultsAndEnvFile(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
envPath := filepath.Join(dir, ".env")
|
||||
if err := os.WriteFile(envPath, []byte("POP3_HOST=mail.local\nSMTP_PORT=2525\nSMTP_AUTH_REQUIRED=true\nSMTP_ALLOW_INSECURE_AUTH=true\nDATA_DIR="+dir+"\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
cfg, err := Load(envPath)
|
||||
if err != nil {
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
|
||||
if cfg.AccountID != "default" {
|
||||
t.Fatalf("AccountID = %q, want default", cfg.AccountID)
|
||||
}
|
||||
if cfg.POP3.Host != "mail.local" {
|
||||
t.Fatalf("POP3.Host = %q", cfg.POP3.Host)
|
||||
}
|
||||
if cfg.POP3.Port != 110 {
|
||||
t.Fatalf("POP3.Port = %d, want 110", cfg.POP3.Port)
|
||||
}
|
||||
if cfg.SMTP.Port != 2525 {
|
||||
t.Fatalf("SMTP.Port = %d, want 2525", cfg.SMTP.Port)
|
||||
}
|
||||
if !cfg.SMTP.AuthRequired {
|
||||
t.Fatal("SMTP.AuthRequired = false, want true")
|
||||
}
|
||||
if !cfg.SMTP.AllowInsecureAuth {
|
||||
t.Fatal("SMTP.AllowInsecureAuth = false, want true")
|
||||
}
|
||||
if cfg.HTTP.Host != "127.0.0.1" || cfg.HTTP.Port != 8765 {
|
||||
t.Fatalf("HTTP default = %s:%d", cfg.HTTP.Host, cfg.HTTP.Port)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user