-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain_test.go
More file actions
85 lines (75 loc) · 1.8 KB
/
Copy pathmain_test.go
File metadata and controls
85 lines (75 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package main
import (
"advrider-notifier/email"
"advrider-notifier/pkg/notifier"
"log/slog"
"os"
"strings"
"testing"
)
func TestGetText(t *testing.T) {
tests := []struct {
name string
input string
want string
}{
{
name: "simple text",
input: "hello world",
want: "hello world",
},
{
name: "whitespace trimming",
input: " hello world ",
want: "hello world",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := strings.TrimSpace(tt.input); got != tt.want {
t.Errorf("getText() = %v, want %v", got, tt.want)
}
})
}
}
func TestFormatEmailBody(t *testing.T) {
logger := slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{
Level: slog.LevelInfo,
}))
mockProvider := email.NewMockProvider(logger)
sender := email.New(mockProvider, logger, "https://test.example.com")
sub := ¬ifier.Subscription{
Email: "test@example.com",
Token: "test-token-1234567890abcdef1234567890abcdef1234567890abcdef1234",
}
thread := ¬ifier.Thread{
ThreadID: "12345",
ThreadURL: "https://advrider.com/f/threads/test.12345/",
}
posts := []*notifier.Post{
{
ID: "67890",
Author: "TestUser",
Content: "This is a test post",
Timestamp: "2025-10-13T12:00:00Z",
URL: "https://advrider.com/f/threads/test.12345/#post-67890",
},
}
// Use reflection to access private method for testing
// Or we can test via the public SendNotification method
// For now, let's just verify the types work
_ = sender
_ = sub
_ = thread
_ = posts
// Basic integration test - ensure types are compatible
if sub.Email == "" {
t.Error("Subscription email should not be empty")
}
if thread.ThreadID == "" {
t.Error("Thread ID should not be empty")
}
if len(posts) == 0 {
t.Error("Posts should not be empty")
}
}