(t *testing.T)
| 32 | var failingPaginationUUID = uuid.MustParse("fba6966a-9061-4111-8e1a-f6a9fbea4b16") |
| 33 | |
| 34 | func TestInboxNotification_Watch(t *testing.T) { |
| 35 | t.Parallel() |
| 36 | |
| 37 | // I skip these tests specifically on windows as for now they are flaky - only on Windows. |
| 38 | // For now the idea is that the runner takes too long to insert the entries, could be worth |
| 39 | // investigating a manual Tx. |
| 40 | // see: https://github.com/coder/internal/issues/503 |
| 41 | if runtime.GOOS == "windows" { |
| 42 | t.Skip("our runners are randomly taking too long to insert entries") |
| 43 | } |
| 44 | |
| 45 | t.Run("Failure Modes", func(t *testing.T) { |
| 46 | tests := []struct { |
| 47 | name string |
| 48 | expectedError string |
| 49 | listTemplate string |
| 50 | listTarget string |
| 51 | listReadStatus string |
| 52 | listStartingBefore string |
| 53 | }{ |
| 54 | {"nok - wrong targets", `Query param "targets" has invalid values`, "", "wrong_target", "", ""}, |
| 55 | {"nok - wrong templates", `Query param "templates" has invalid values`, "wrong_template", "", "", ""}, |
| 56 | {"nok - wrong read status", "starting_before query parameter should be any of 'all', 'read', 'unread'", "", "", "erroneous", ""}, |
| 57 | } |
| 58 | |
| 59 | for _, tt := range tests { |
| 60 | t.Run(tt.name, func(t *testing.T) { |
| 61 | t.Parallel() |
| 62 | |
| 63 | client, _, _ := coderdtest.NewWithAPI(t, &coderdtest.Options{}) |
| 64 | firstUser := coderdtest.CreateFirstUser(t, client) |
| 65 | client, _ = coderdtest.CreateAnotherUser(t, client, firstUser.OrganizationID) |
| 66 | |
| 67 | ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) |
| 68 | defer cancel() |
| 69 | |
| 70 | resp, err := client.Request(ctx, http.MethodGet, "/api/v2/notifications/inbox/watch", nil, |
| 71 | codersdk.ListInboxNotificationsRequestToQueryParams(codersdk.ListInboxNotificationsRequest{ |
| 72 | Targets: tt.listTarget, |
| 73 | Templates: tt.listTemplate, |
| 74 | ReadStatus: tt.listReadStatus, |
| 75 | StartingBefore: tt.listStartingBefore, |
| 76 | })...) |
| 77 | require.NoError(t, err) |
| 78 | defer resp.Body.Close() |
| 79 | |
| 80 | err = codersdk.ReadBodyAsError(resp) |
| 81 | require.ErrorContains(t, err, tt.expectedError) |
| 82 | }) |
| 83 | } |
| 84 | }) |
| 85 | |
| 86 | t.Run("OK", func(t *testing.T) { |
| 87 | t.Parallel() |
| 88 | |
| 89 | ctx := testutil.Context(t, testutil.WaitLong) |
| 90 | logger := testutil.Logger(t) |
| 91 |
nothing calls this directly
no test coverage detected