@@ -165,7 +165,7 @@ func TestAdminServer(t *testing.T) {
165165 for _ , tt := range tests {
166166 t .Run (tt .name , func (t * testing.T ) {
167167 // Special handling for workflows time filter test
168- if tt .name == "List Workflows endpoint " {
168+ if tt .name == "List endpoints time filtering " {
169169 // Create first workflow
170170 handle1 , err := RunAsWorkflow (ctx , testWorkflow , "workflow1" )
171171 require .NoError (t , err , "Failed to create first workflow" )
@@ -190,7 +190,7 @@ func TestAdminServer(t *testing.T) {
190190
191191 // Test 1: Query with start_time before timeBetween (should get both workflows)
192192 reqBody1 := map [string ]any {
193- "start_time" : timeBetween .Add (- 2 * time .Second ).UnixMilli ( ),
193+ "start_time" : timeBetween .Add (- 2 * time .Second ).Format ( time . RFC3339 ),
194194 "limit" : 10 ,
195195 }
196196 req1 , err := http .NewRequest (tt .method , tt .endpoint , bytes .NewBuffer (mustMarshal (reqBody1 )))
@@ -203,24 +203,36 @@ func TestAdminServer(t *testing.T) {
203203
204204 assert .Equal (t , tt .expectedStatus , resp1 .StatusCode )
205205
206- var workflows1 []WorkflowStatus
206+ var workflows1 []map [ string ] any
207207 err = json .NewDecoder (resp1 .Body ).Decode (& workflows1 )
208208 require .NoError (t , err , "Failed to decode workflows response 1" )
209209
210210 // Should have exactly 2 workflows that we just created
211211 assert .Equal (t , 2 , len (workflows1 ), "Expected exactly 2 workflows with start_time before timeBetween" )
212212
213+ // Verify timestamps are epoch milliseconds
214+ timeBetweenMillis := timeBetween .UnixMilli ()
215+ for _ , wf := range workflows1 {
216+ _ , ok := wf ["created_at" ].(float64 )
217+ require .True (t , ok , "created_at should be a number" )
218+ }
219+ // Verify the timestamp is around timeBetween (within 2 seconds before or after)
220+ assert .Less (t , int64 (workflows1 [0 ]["created_at" ].(float64 )), timeBetweenMillis , "first workflow CreatedAt should be before timeBetween" )
221+ assert .Greater (t , int64 (workflows1 [1 ]["created_at" ].(float64 )), timeBetweenMillis , "second workflow CreatedAt should be before timeBetween" )
222+
213223 // Verify both workflow IDs are present
214224 foundIDs1 := make (map [string ]bool )
215225 for _ , wf := range workflows1 {
216- foundIDs1 [wf .ID ] = true
226+ id , ok := wf ["workflow_uuid" ].(string )
227+ require .True (t , ok , "workflow_uuid should be a string" )
228+ foundIDs1 [id ] = true
217229 }
218230 assert .True (t , foundIDs1 [workflowID1 ], "Expected to find first workflow ID in results" )
219231 assert .True (t , foundIDs1 [workflowID2 ], "Expected to find second workflow ID in results" )
220232
221233 // Test 2: Query with start_time after timeBetween (should get only second workflow)
222234 reqBody2 := map [string ]any {
223- "start_time" : timeBetween .UnixMilli ( ),
235+ "start_time" : timeBetween .Format ( time . RFC3339 ),
224236 "limit" : 10 ,
225237 }
226238 req2 , err := http .NewRequest (tt .method , tt .endpoint , bytes .NewBuffer (mustMarshal (reqBody2 )))
@@ -233,19 +245,21 @@ func TestAdminServer(t *testing.T) {
233245
234246 assert .Equal (t , tt .expectedStatus , resp2 .StatusCode )
235247
236- var workflows2 []WorkflowStatus
248+ var workflows2 []map [ string ] any
237249 err = json .NewDecoder (resp2 .Body ).Decode (& workflows2 )
238250 require .NoError (t , err , "Failed to decode workflows response 2" )
239251
240252 // Should have exactly 1 workflow (the second one)
241253 assert .Equal (t , 1 , len (workflows2 ), "Expected exactly 1 workflow with start_time after timeBetween" )
242254
243255 // Verify it's the second workflow
244- assert .Equal (t , workflowID2 , workflows2 [0 ].ID , "Expected second workflow ID in results" )
256+ id2 , ok := workflows2 [0 ]["workflow_uuid" ].(string )
257+ require .True (t , ok , "workflow_uuid should be a string" )
258+ assert .Equal (t , workflowID2 , id2 , "Expected second workflow ID in results" )
245259
246260 // Also test end_time filter
247261 reqBody3 := map [string ]any {
248- "end_time" : timeBetween .UnixMilli ( ),
262+ "end_time" : timeBetween .Format ( time . RFC3339 ),
249263 "limit" : 10 ,
250264 }
251265 req3 , err := http .NewRequest (tt .method , tt .endpoint , bytes .NewBuffer (mustMarshal (reqBody3 )))
@@ -258,15 +272,17 @@ func TestAdminServer(t *testing.T) {
258272
259273 assert .Equal (t , tt .expectedStatus , resp3 .StatusCode )
260274
261- var workflows3 []WorkflowStatus
275+ var workflows3 []map [ string ] any
262276 err = json .NewDecoder (resp3 .Body ).Decode (& workflows3 )
263277 require .NoError (t , err , "Failed to decode workflows response 3" )
264278
265279 // Should have exactly 1 workflow (the first one)
266280 assert .Equal (t , 1 , len (workflows3 ), "Expected exactly 1 workflow with end_time before timeBetween" )
267281
268282 // Verify it's the first workflow
269- assert .Equal (t , workflowID1 , workflows3 [0 ].ID , "Expected first workflow ID in results" )
283+ id3 , ok := workflows3 [0 ]["workflow_uuid" ].(string )
284+ require .True (t , ok , "workflow_uuid should be a string" )
285+ assert .Equal (t , workflowID1 , id3 , "Expected first workflow ID in results" )
270286
271287 // Test 4: Query with empty body (should return all workflows)
272288 req4 , err := http .NewRequest (tt .method , tt .endpoint , nil )
@@ -278,7 +294,7 @@ func TestAdminServer(t *testing.T) {
278294
279295 assert .Equal (t , tt .expectedStatus , resp4 .StatusCode )
280296
281- var workflows4 []WorkflowStatus
297+ var workflows4 []map [ string ] any
282298 err = json .NewDecoder (resp4 .Body ).Decode (& workflows4 )
283299 require .NoError (t , err , "Failed to decode workflows response 4" )
284300
@@ -288,7 +304,9 @@ func TestAdminServer(t *testing.T) {
288304 // Verify both workflow IDs are present
289305 foundIDs4 := make (map [string ]bool )
290306 for _ , wf := range workflows4 {
291- foundIDs4 [wf .ID ] = true
307+ id , ok := wf ["workflow_uuid" ].(string )
308+ require .True (t , ok , "workflow_uuid should be a string" )
309+ foundIDs4 [id ] = true
292310 }
293311 assert .True (t , foundIDs4 [workflowID1 ], "Expected to find first workflow ID in empty body results" )
294312 assert .True (t , foundIDs4 [workflowID2 ], "Expected to find second workflow ID in empty body results" )
0 commit comments