MCPcopy Index your code
hub / github.com/coder/coder / TestCache_BuildTime

Function TestCache_BuildTime

coderd/metricscache/metricscache_test.go:135–293  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

133}
134
135func 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 {

Callers

nothing calls this directly

Calls 15

ContextFunction · 0.92
LoggerFunction · 0.92
OrganizationFunction · 0.92
UserFunction · 0.92
TemplateFunction · 0.92
TemplateVersionFunction · 0.92
WorkspaceFunction · 0.92
ProvisionerJobFunction · 0.92
WorkspaceBuildFunction · 0.92
WorkspaceTransitionTypeAlias · 0.92
dateFunction · 0.85
clockTimeFunction · 0.85

Tested by

no test coverage detected