diff --git a/internal/cli/posts_test.go b/internal/cli/posts_test.go index ebc04b6..ed8b597 100644 --- a/internal/cli/posts_test.go +++ b/internal/cli/posts_test.go @@ -21,12 +21,16 @@ func TestPostsLs(t *testing.T) { } now := time.Date(2026, 3, 1, 9, 30, 0, 0, time.UTC) e.s.Now = func() time.Time { return now } - rcpts := []store.NewOutbound{{From: "b@x.org", Rcpt: "a@x.com"}, {From: "b@x.org", Rcpt: "b@x.com"}, {From: "b@x.org", Rcpt: "c@x.com"}, {From: "b@x.org", Rcpt: "d@x.com"}} + var rcpts []store.NewOutbound + for i := 0; i < 7; i++ { + rcpts = append(rcpts, store.NewOutbound{From: "b@x.org", Rcpt: fmt.Sprintf("u%d@x.com", i)}) + } e.s.EnqueuePost(l.ID, "mid:<1@x>", []byte("Message-ID: <1@x>\r\nSubject: March issue\r\n\r\nb"), rcpts) due, _ := e.s.DueOutbox(10) - e.s.CompleteOutbox(due[0].ID) - e.s.CompleteOutbox(due[1].ID) - e.s.FailOutbox(due[2].ID, "no") + for _, d := range due[:4] { + e.s.CompleteOutbox(d.ID) + } + e.s.FailOutbox(due[4].ID, "no") now = now.Add(time.Hour) e.s.EnqueuePost(l.ID, "mid:<2@x>", []byte("Message-ID: <2@x>\r\n\r\nb"), nil) @@ -41,7 +45,7 @@ func TestPostsLs(t *testing.T) { if f := strings.Fields(lines[1]); strings.Join(f, " ") != "2 2026-03-01 10:30 (no subject) 0 0 0 0 0" { t.Fatalf("newest first: %q", lines[1]) } - if f := strings.Fields(lines[2]); strings.Join(f, " ") != "1 2026-03-01 09:30 March issue 4 2 1 1 0" { + if f := strings.Fields(lines[2]); strings.Join(f, " ") != "1 2026-03-01 09:30 March issue 7 4 2 1 0" { t.Fatalf("row: %q", lines[2]) } @@ -50,7 +54,7 @@ func TestPostsLs(t *testing.T) { } var js []map[string]any if err := json.Unmarshal([]byte(e.ok(t, "--json", "posts", "ls", "dev@example.org")), &js); err != nil || len(js) != 2 || - js[1]["subject"] != "March issue" || js[1]["pending"] != float64(1) || js[1]["message_id"] != "<1@x>" { + js[1]["subject"] != "March issue" || js[1]["pending"] != float64(2) || js[1]["message_id"] != "<1@x>" { t.Fatalf("json: %v %v", js, err) } } diff --git a/internal/store/posts_test.go b/internal/store/posts_test.go index 1c9bce1..24a4960 100644 --- a/internal/store/posts_test.go +++ b/internal/store/posts_test.go @@ -268,6 +268,9 @@ func TestListPostsNewestFirstWithALimit(t *testing.T) { if some, _ := s.ListPosts(dev.ID, 7); len(some) != 7 { t.Fatalf("limit 7: %d", len(some)) } + if over, _ := s.ListPosts(dev.ID, 201); len(over) != 200 { + t.Fatalf("limit 201: %d", len(over)) + } if exact, _ := s.ListPosts(dev.ID, 200); len(exact) != 200 { t.Fatalf("limit 200: %d", len(exact)) }