Follow up for https://github.com/kubernetes/kubernetes/pull/47003
This commit is contained in:
@@ -21,7 +21,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MessagesgCountMap contains occurance for each error message.
|
// MessageCountMap contains occurance for each error message.
|
||||||
type MessageCountMap map[string]int
|
type MessageCountMap map[string]int
|
||||||
|
|
||||||
// Aggregate represents an object that contains multiple errors, but does not
|
// Aggregate represents an object that contains multiple errors, but does not
|
||||||
|
@@ -266,7 +266,7 @@ func TestFlatten(t *testing.T) {
|
|||||||
func TestCreateAggregateFromMessageCountMap(t *testing.T) {
|
func TestCreateAggregateFromMessageCountMap(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
mcp MessageCountMap
|
mcm MessageCountMap
|
||||||
expected Aggregate
|
expected Aggregate
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@@ -279,6 +279,11 @@ func TestCreateAggregateFromMessageCountMap(t *testing.T) {
|
|||||||
MessageCountMap{"abc": 2, "ghi": 1},
|
MessageCountMap{"abc": 2, "ghi": 1},
|
||||||
aggregate{fmt.Errorf("abc (repeated 2 times)"), fmt.Errorf("ghi")},
|
aggregate{fmt.Errorf("abc (repeated 2 times)"), fmt.Errorf("ghi")},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"input has multiple messages",
|
||||||
|
MessageCountMap{"ghi": 1, "abc": 2},
|
||||||
|
aggregate{fmt.Errorf("abc (repeated 2 times)"), fmt.Errorf("ghi")},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var expected, agg []error
|
var expected, agg []error
|
||||||
@@ -288,8 +293,8 @@ func TestCreateAggregateFromMessageCountMap(t *testing.T) {
|
|||||||
expected = testCase.expected.Errors()
|
expected = testCase.expected.Errors()
|
||||||
sort.Slice(expected, func(i, j int) bool { return expected[i].Error() < expected[j].Error() })
|
sort.Slice(expected, func(i, j int) bool { return expected[i].Error() < expected[j].Error() })
|
||||||
}
|
}
|
||||||
if testCase.mcp != nil {
|
if testCase.mcm != nil {
|
||||||
agg = CreateAggregateFromMessageCountMap(testCase.mcp).Errors()
|
agg = CreateAggregateFromMessageCountMap(testCase.mcm).Errors()
|
||||||
sort.Slice(agg, func(i, j int) bool { return agg[i].Error() < agg[j].Error() })
|
sort.Slice(agg, func(i, j int) bool { return agg[i].Error() < agg[j].Error() })
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(expected, agg) {
|
if !reflect.DeepEqual(expected, agg) {
|
||||||
|
Reference in New Issue
Block a user