1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2024-12-14 11:57:51 +00:00

Reproducible output from expression matching

Fix flakyness of unit tests by adding back the sorting of matched
feature elements that was unadvisedly removed in
63c22551df. This might help debugging some
corner cases in real-life scenarios (when using templating), too.
This commit is contained in:
Markus Lehtonen 2023-11-24 16:27:38 +02:00
parent ed8898de6a
commit f489ca98b5

View file

@ -308,6 +308,8 @@ func (m *MatchExpressionSet) MatchGetKeys(keys map[string]Nil) (bool, []MatchedE
}
ret = append(ret, MatchedElement{"Name": n})
}
// Sort for reproducible output
sort.Slice(ret, func(i, j int) bool { return ret[i]["Name"] < ret[j]["Name"] })
return true, ret, nil
}
@ -333,6 +335,8 @@ func (m *MatchExpressionSet) MatchGetValues(values map[string]string) (bool, []M
}
ret = append(ret, MatchedElement{"Name": n, "Value": values[n]})
}
// Sort for reproducible output
sort.Slice(ret, func(i, j int) bool { return ret[i]["Name"] < ret[j]["Name"] })
return true, ret, nil
}