Skip to content

Commit

Permalink
Only fail mapping when multiple components claim the same test with t…
Browse files Browse the repository at this point in the history
…he same highest priority
  • Loading branch information
xueqzhan committed Nov 25, 2024
1 parent 3980996 commit 3908437
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions pkg/components/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,21 @@ func testInfoLogFields(testInfo *v1.TestInfo) log.Fields {

func getHighestPriority(ownerships []*v1.TestOwnership) (*v1.TestOwnership, error) {
var highest *v1.TestOwnership
// First find the highest priority
for _, ownership := range ownerships {
if highest != nil && ownership.Priority == highest.Priority {
return nil, fmt.Errorf("suite=%q test=%q is claimed by %s, %s - unable to resolve conflict "+
"-- please use priority field", highest.Suite, highest.Name, highest.Component, ownership.Component)
}

if highest == nil || ownership.Priority > highest.Priority {
highest = ownership
}
}
// Now find duplicates with the same highest priority
if highest != nil {
for _, ownership := range ownerships {
if ownership.Priority == highest.Priority && ownership != highest {
return nil, fmt.Errorf("suite=%q test=%q is claimed by %s, %s - unable to resolve conflict "+
"-- please use priority field", highest.Suite, highest.Name, highest.Component, ownership.Component)
}
}
}

return highest, nil
}
Expand Down

0 comments on commit 3908437

Please sign in to comment.