nolint:thelper
(t *testing.T, ctx context.Context, m *uitask.Manager)
| 45 | |
| 46 | //nolint:thelper |
| 47 | func testUITaskInternal(t *testing.T, ctx context.Context, m *uitask.Manager) { |
| 48 | t.Parallel() |
| 49 | |
| 50 | m.MaxLogMessagesPerTask = 3 |
| 51 | m.MaxFinishedTasks = 3 |
| 52 | |
| 53 | verifyTaskList(t, m, nil) |
| 54 | |
| 55 | var tid1a, tid1, tid2, tid3, tid4, tid5 string |
| 56 | |
| 57 | m.Run(ctx, "some-kind", "test-1", func(ctx context.Context, ctrl uitask.Controller) error { |
| 58 | tid1a = ctrl.CurrentTaskID() |
| 59 | |
| 60 | tsk, ok := m.GetTask(tid1a) |
| 61 | if !ok { |
| 62 | t.Fatalf("task not found") |
| 63 | } |
| 64 | |
| 65 | if got, want := tsk.Description, "test-1"; got != want { |
| 66 | t.Fatalf("invalid task description %v, want %v", got, want) |
| 67 | } |
| 68 | |
| 69 | if got, want := tsk.Status, uitask.StatusRunning; got != want { |
| 70 | t.Fatalf("invalid task status %v, want %v", got, want) |
| 71 | } |
| 72 | |
| 73 | verifyTaskList(t, m, map[string]uitask.Status{ |
| 74 | tid1a: uitask.StatusRunning, |
| 75 | }) |
| 76 | |
| 77 | verifyTaskLog(t, m, tid1a, nil) |
| 78 | log(ctx).Debug("first") |
| 79 | ignoredLog(ctx).Debug("this is ignored") |
| 80 | log(ctx).Info("iii") |
| 81 | verifyTaskLog(t, m, tid1a, []string{ |
| 82 | "first", |
| 83 | "iii", |
| 84 | }) |
| 85 | log(ctx).Info("www") |
| 86 | log(ctx).Error("eee") |
| 87 | |
| 88 | // 'first' has aged out |
| 89 | verifyTaskLog(t, m, tid1a, []string{ |
| 90 | "iii", |
| 91 | "www", |
| 92 | "eee", |
| 93 | }) |
| 94 | |
| 95 | ctrl.ReportProgressInfo("doing something") |
| 96 | ctrl.ReportCounters(map[string]uitask.CounterValue{ |
| 97 | "foo": uitask.SimpleCounter(1), |
| 98 | "bar": uitask.BytesCounter(2), |
| 99 | "foo-warn": uitask.WarningCounter(3), |
| 100 | "bar-warn": uitask.WarningBytesCounter(4), |
| 101 | "foo-err": uitask.ErrorCounter(5), |
| 102 | "bar-err": uitask.ErrorBytesCounter(6), |
| 103 | "foo-notice": uitask.NoticeCounter(7), |
| 104 | "bar-notice": uitask.NoticeBytesCounter(8), |
no test coverage detected