| 1 | package calendartest |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "errors" |
| 6 | "net/url" |
| 7 | "testing" |
| 8 | |
| 9 | calendar "amadan.net/oficina/calendar/internal/calendar" |
| 10 | ) |
| 11 | |
| 12 | func TestStrictRangeRejectsUnreadableBusySeries(t *testing.T) { |
| 13 | for _, field := range []string{"tz", "start_local", "end_local"} { |
| 14 | t.Run(field, func(t *testing.T) { |
| 15 | app, session := signedIn(t, "someone@example.com") |
| 16 | createEvent(t, app.Handler(), session, url.Values{"title": {"fixture"}, "start": {testAt(1, "09:00")}, "end": {testAt(1, "10:00")}, "kind": {"meeting"}, "status": {"confirmed"}, "repeat": {"daily"}}) |
| 17 | if _, err := app.DBForTest().Exec("UPDATE events SET "+field+" = ? WHERE rrule <> ''", "invalid"); err != nil { |
| 18 | t.Fatal(err) |
| 19 | } |
| 20 | person := app.PersonByAddressForTest(t, "someone@example.com") |
| 21 | from, to := window(t, 1, 3) |
| 22 | if _, err := app.StoreForTest().EventsInRange(context.Background(), person.ID, from, to); err != nil { |
| 23 | t.Fatalf("tolerant view: %v", err) |
| 24 | } |
| 25 | if _, err := app.StoreForTest().EventsInRangeStrict(context.Background(), person.ID, from, to); !errors.Is(err, calendar.ErrIncompleteExpansion) { |
| 26 | t.Fatalf("strict result=%v want incomplete expansion", err) |
| 27 | } |
| 28 | }) |
| 29 | } |
| 30 | } |
| 31 | |