@@ -112,9 +112,7 @@ func TestAdminRuns_List(t *testing.T) {
112
112
require .NoError (t , err )
113
113
require .NotEmpty (t , rl .Items )
114
114
115
- assert .Equal (t , r1 .Status , RunPlanning )
116
115
assert .Equal (t , adminRunItemsContainsID (rl .Items , r1 .ID ), false )
117
- assert .Equal (t , r2 .Status , RunPending )
118
116
assert .Equal (t , adminRunItemsContainsID (rl .Items , r2 .ID ), true )
119
117
})
120
118
@@ -189,7 +187,10 @@ func TestAdminRuns_ForceCancel(t *testing.T) {
189
187
t .Run ("with can force cancel" , func (t * testing.T ) {
190
188
rTestPlanning , err := client .Runs .Read (ctx , rTest1 .ID )
191
189
require .NoError (t , err )
192
- assert .Equal (t , RunPlanning , rTestPlanning .Status )
190
+
191
+ ctxPollRunStatus , cancelPollPlanned := context .WithTimeout (ctx , 2 * time .Minute )
192
+ defer cancelPollPlanned ()
193
+ pollRunStatus (t , client , ctxPollRunStatus , rTestPlanning , []RunStatus {RunPlanning , RunPlanned , RunCostEstimated })
193
194
194
195
require .NotNil (t , rTestPlanning .Actions )
195
196
require .NotNil (t , rTestPlanning .Permissions )
@@ -198,7 +199,8 @@ func TestAdminRuns_ForceCancel(t *testing.T) {
198
199
199
200
rTestPending , err := client .Runs .Read (ctx , rTest2 .ID )
200
201
require .NoError (t , err )
201
- assert .Equal (t , RunPending , rTestPending .Status )
202
+
203
+ pollRunStatus (t , client , ctxPollRunStatus , rTest2 , []RunStatus {RunPending })
202
204
203
205
require .NotNil (t , rTestPlanning .Actions )
204
206
require .NotNil (t , rTestPlanning .Permissions )
@@ -240,15 +242,23 @@ func TestAdminRuns_ListFilterByDates(t *testing.T) {
240
242
defer wTestCleanup ()
241
243
242
244
timestamp1 := time .Now ().Format (time .RFC3339 )
245
+ // Sleeping helps ensure that the timestamps on client and server don't
246
+ // need to be exactly in sync
247
+ time .Sleep (2 * time .Second )
248
+
243
249
rTest1 , rCleanup1 := createRun (t , client , wTest )
244
250
defer rCleanup1 ()
245
251
246
252
rTest2 , rCleanup2 := createRun (t , client , wTest )
247
253
defer rCleanup2 ()
254
+
255
+ time .Sleep (2 * time .Second )
248
256
timestamp2 := time .Now ().Format (time .RFC3339 )
249
257
250
258
_ , rCleanup3 := createRun (t , client , wTest )
251
259
defer rCleanup3 ()
260
+
261
+ time .Sleep (2 * time .Second )
252
262
timestamp3 := time .Now ().Format (time .RFC3339 )
253
263
254
264
t .Run ("has valid date ranges" , func (t * testing.T ) {
0 commit comments