summaryrefslogtreecommitdiffstats
path: root/internal/thread/thread_test.go
blob: 146ae0c56eb0ba351b976808de4b44a22bfc50c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package thread

import (
	"testing"

	"aegis/internal/nntp"
)

func TestBuildUsesLastReference(t *testing.T) {
	roots := Build([]nntp.ArticleHeader{
		{Number: 1, MessageID: "<root@example>", Subject: "topic"},
		{Number: 2, MessageID: "<reply@example>", References: "<root@example>"},
		{Number: 3, MessageID: "<nested@example>", References: "<root@example> <reply@example>"},
	})
	if len(roots) != 1 || len(roots[0].Children) != 1 || len(roots[0].Children[0].Children) != 1 {
		t.Fatalf("unexpected thread tree: %#v", roots)
	}
}