TestTaskTableConvert verifies all task fields are converted when reducing a `Task` to a `TaskTable`. This test is a guard rail to prevent developer oversight mistakes.
(t *testing.T)
| 64 | // when reducing a `Task` to a `TaskTable`. |
| 65 | // This test is a guard rail to prevent developer oversight mistakes. |
| 66 | func TestTaskTableConvert(t *testing.T) { |
| 67 | t.Parallel() |
| 68 | |
| 69 | staticRandoms := &testutil.Random{ |
| 70 | String: func() string { return "foo" }, |
| 71 | Bool: func() bool { return true }, |
| 72 | Int: func() int64 { return 500 }, |
| 73 | Uint: func() uint64 { return 126 }, |
| 74 | Float: func() float64 { return 3.14 }, |
| 75 | Complex: func() complex128 { return 6.24 }, |
| 76 | Time: func() time.Time { |
| 77 | return time.Date(2020, 5, 2, 5, 19, 21, 30, time.UTC) |
| 78 | }, |
| 79 | } |
| 80 | |
| 81 | // Copies the approach taken by TestWorkspaceTableConvert. |
| 82 | // |
| 83 | // If you use 'PopulateStruct' to create 2 tasks, using the same |
| 84 | // "random" values for each type. Then they should be identical. |
| 85 | // |
| 86 | // So if 'task.TaskTable()' was missing any fields in its |
| 87 | // conversion, the comparison would fail. |
| 88 | |
| 89 | var task Task |
| 90 | err := testutil.PopulateStruct(&task, staticRandoms) |
| 91 | require.NoError(t, err) |
| 92 | |
| 93 | var subset TaskTable |
| 94 | err = testutil.PopulateStruct(&subset, staticRandoms) |
| 95 | require.NoError(t, err) |
| 96 | |
| 97 | require.Equal(t, task.TaskTable(), subset, |
| 98 | "'task.TaskTable()' is not missing at least 1 field when converting to 'TaskTable'. "+ |
| 99 | "To resolve this, go to the 'func (t Task) TaskTable()' and ensure all fields are converted.") |
| 100 | } |
| 101 | |
| 102 | // TestAuditLogsQueryConsistency ensures that GetAuditLogsOffset and CountAuditLogs |
| 103 | // have identical WHERE clauses to prevent filtering inconsistencies. |
nothing calls this directly
no test coverage detected