aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/email/lore/parse_test.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-04-12 11:17:35 +0200
committerAleksandr Nogikh <wp32pw@gmail.com>2023-04-12 13:55:59 +0200
commit5d17667bb6ecde104eff665d3c096ac2b7984648 (patch)
tree6915c7b58d1d19ab402d78f8fec6878d51cf074e /pkg/email/lore/parse_test.go
parent02abcd096cbcce690366f853c8bc065d22aa205c (diff)
all: refactor discussion processing code
Now that too much logic seems to be duplicated in tools/syz-lore and dahsboard/app/discussion.go, it's time to refactor the code. Factor out the code that decides whether an incoming email message should start a new thread or be appended to the previous one. Restructure pkg/email/lore so that email processing matches the one-by-one approach of reporting_email.go.
Diffstat (limited to 'pkg/email/lore/parse_test.go')
-rw-r--r--pkg/email/lore/parse_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/pkg/email/lore/parse_test.go b/pkg/email/lore/parse_test.go
index 86e2b51b7..2343a7c26 100644
--- a/pkg/email/lore/parse_test.go
+++ b/pkg/email/lore/parse_test.go
@@ -10,6 +10,7 @@ import (
"time"
"github.com/google/go-cmp/cmp"
+ "github.com/google/syzkaller/dashboard/dashapi"
"github.com/google/syzkaller/pkg/email"
)
@@ -112,6 +113,7 @@ Bug report`,
"<A-Base>": {
Subject: "Thread A",
MessageID: "<A-Base>",
+ Type: dashapi.DiscussionReport,
Messages: []*email.Email{
{
MessageID: "<A-Base>",
@@ -144,6 +146,7 @@ Bug report`,
"<Bug>": {
Subject: "[syzbot] Some bug",
MessageID: "<Bug>",
+ Type: dashapi.DiscussionReport,
BugIDs: []string{"4564456"},
Messages: []*email.Email{
{
@@ -180,6 +183,7 @@ Bug report`,
"<Patch>": {
Subject: "[PATCH] Some bug fixed",
MessageID: "<Patch>",
+ Type: dashapi.DiscussionPatch,
BugIDs: []string{"12345"},
Messages: []*email.Email{
{
@@ -196,6 +200,7 @@ Bug report`,
"<Sub-Discussion>": {
Subject: "[syzbot] Some bug 2",
MessageID: "<Sub-Discussion>",
+ Type: dashapi.DiscussionReport,
BugIDs: []string{"4564456"},
Messages: []*email.Email{
{
@@ -244,3 +249,35 @@ Bug report`,
t.Fatalf("Expected %d threads, got %d", len(expected), len(threads))
}
}
+
+func TestDiscussionType(t *testing.T) {
+ tests := []struct {
+ msg *email.Email
+ ret dashapi.DiscussionType
+ }{
+ {
+ msg: &email.Email{
+ Subject: "[PATCH] Bla-bla",
+ },
+ ret: dashapi.DiscussionPatch,
+ },
+ {
+ msg: &email.Email{
+ Subject: "[syzbot] Monthly ext4 report",
+ },
+ ret: dashapi.DiscussionReminder,
+ },
+ {
+ msg: &email.Email{
+ Subject: "[syzbot] WARNING in abcd",
+ },
+ ret: dashapi.DiscussionReport,
+ },
+ }
+ for _, test := range tests {
+ got := DiscussionType(test.msg)
+ if got != test.ret {
+ t.Fatalf("expected %v got %v for %v", test.ret, got, test.msg)
+ }
+ }
+}