@@ -214,6 +214,8 @@ func TestDatabase_AddJob(t *testing.T) {
214214 assert .NoError (t , db .AddJob (ctx , & job ))
215215 assertSingleNotificationReceived (t , pressureUpdates )
216216
217+ job .Labels = []string {"amd64" , "large" }
218+
217219 jobs , err := db .ListJobs (ctx , job .Platform )
218220 assert .NoError (t , err )
219221
@@ -304,6 +306,32 @@ func TestDatabase_AddJob_FlavorSelection(t *testing.T) {
304306 assert .Nil (t , jobs [0 ].AssignedFlavor )
305307}
306308
309+ // Verify that GitHub's default labels ("self-hosted", "linux") are stripped
310+ // from job labels on insertion, so flavors don't need to include them.
311+ func TestDatabase_AddJob_DefaultLabelsStripped (t * testing.T ) {
312+ db := setupDatabase (t )
313+ defer teardownDatabase (t )
314+ ctx := t .Context ()
315+
316+ assert .NoError (t , db .AddFlavor (ctx , & Flavor {
317+ Platform : "github" ,
318+ Name : "github-x64-noble" ,
319+ Labels : []string {"x64" , "noble" },
320+ Priority : 100 ,
321+ }))
322+
323+ assert .NoError (t , db .AddJob (ctx , & Job {
324+ Platform : "github" ,
325+ ID : "1" ,
326+ Labels : []string {"self-hosted" , "linux" , "x64" , "noble" },
327+ }))
328+
329+ jobs , err := db .ListJobs (ctx , "github" , ListJobOptions {WithId : "1" })
330+ assert .NoError (t , err )
331+ assert .Equal (t , "github-x64-noble" , * jobs [0 ].AssignedFlavor )
332+ assert .Equal (t , []string {"x64" , "noble" }, jobs [0 ].Labels )
333+ }
334+
307335func TestDatabase_AddJob_EqualPriority (t * testing.T ) {
308336 db := setupDatabase (t )
309337 defer teardownDatabase (t )
@@ -364,13 +392,13 @@ func TestDatabase_AddJob_AssignedFlavor(t *testing.T) {
364392 assert .NoError (t , db .AddFlavor (ctx , & Flavor {
365393 Platform : "github" ,
366394 Name : "amd64-small" ,
367- Labels : []string {"self-hosted" , " amd64" , "small" },
395+ Labels : []string {"amd64" , "small" },
368396 Priority : 0 ,
369397 }))
370398 assert .NoError (t , db .AddFlavor (ctx , & Flavor {
371399 Platform : "github" ,
372400 Name : "amd64-large" ,
373- Labels : []string {"self-hosted" , " amd64" , "large" },
401+ Labels : []string {"amd64" , "large" },
374402 Priority : 0 ,
375403 }))
376404 assert .NoError (t , db .AddJob (ctx , & Job {
@@ -405,6 +433,7 @@ func TestDatabase_UpdateJobStarted(t *testing.T) {
405433 assert .NoError (t , db .AddJob (ctx , & job ))
406434 assert .NoError (t , db .UpdateJobStarted (ctx , job .Platform , job .ID , startedAt , map [string ]interface {}{"in_progress" : "in_progress" }))
407435
436+ job .Labels = []string {"amd64" , "large" }
408437 job .StartedAt = & startedAt
409438 job .Raw ["in_progress" ] = "in_progress"
410439
@@ -447,6 +476,7 @@ func TestDatabase_UpdateJobCompleted(t *testing.T) {
447476 assert .NoError (t , db .UpdateJobCompleted (ctx , job .Platform , job .ID , completedAt , map [string ]interface {}{"completed" : "completed" }))
448477 assertSingleNotificationReceived (t , pressureUpdates )
449478
479+ job .Labels = []string {"amd64" , "large" }
450480 job .CompletedAt = & completedAt
451481 job .Raw ["completed" ] = "completed"
452482
0 commit comments