(t *testing.T)
| 133 | } |
| 134 | |
| 135 | func TestCache_BuildTime(t *testing.T) { |
| 136 | t.Parallel() |
| 137 | |
| 138 | someDay := date(2022, 10, 1) |
| 139 | |
| 140 | type jobParams struct { |
| 141 | startedAt time.Time |
| 142 | completedAt time.Time |
| 143 | } |
| 144 | |
| 145 | type args struct { |
| 146 | rows []jobParams |
| 147 | transition database.WorkspaceTransition |
| 148 | } |
| 149 | type want struct { |
| 150 | buildTimeMs int64 |
| 151 | loads bool |
| 152 | } |
| 153 | tests := []struct { |
| 154 | name string |
| 155 | args args |
| 156 | want want |
| 157 | }{ |
| 158 | {"empty", args{}, want{-1, false}}, |
| 159 | { |
| 160 | "one/start", args{ |
| 161 | rows: []jobParams{ |
| 162 | { |
| 163 | startedAt: clockTime(someDay, 10, 1, 0), |
| 164 | completedAt: clockTime(someDay, 10, 1, 10), |
| 165 | }, |
| 166 | }, |
| 167 | transition: database.WorkspaceTransitionStart, |
| 168 | }, want{10 * 1000, true}, |
| 169 | }, |
| 170 | { |
| 171 | "two/stop", args{ |
| 172 | rows: []jobParams{ |
| 173 | { |
| 174 | startedAt: clockTime(someDay, 10, 1, 0), |
| 175 | completedAt: clockTime(someDay, 10, 1, 10), |
| 176 | }, |
| 177 | { |
| 178 | startedAt: clockTime(someDay, 10, 1, 0), |
| 179 | completedAt: clockTime(someDay, 10, 1, 50), |
| 180 | }, |
| 181 | }, |
| 182 | transition: database.WorkspaceTransitionStop, |
| 183 | }, want{10 * 1000, true}, |
| 184 | }, |
| 185 | { |
| 186 | "three/delete", args{ |
| 187 | rows: []jobParams{ |
| 188 | { |
| 189 | startedAt: clockTime(someDay, 10, 1, 0), |
| 190 | completedAt: clockTime(someDay, 10, 1, 10), |
| 191 | }, |
| 192 | { |
nothing calls this directly
no test coverage detected