gomega
gomega copied to clipboard
Matchfields "pops the stack" too far and tells me the name of the type, not the type
In this assertion: https://github.com/squeedee/cartographer/blob/effd797484083d3bf7663fc5529c9b17821d16e7/tests/integration/runnable/runnable_test.go#L843
I use MatchFields against a struct. If the fields actually match, then this test passes, but when they don't, the FailureMessage method of the fields.go matcher tells me that the "Expected" is a string, full error below:
• Failure [2.009 seconds]
Stamping a resource on Runnable Creation
/Users/vmware/workspace/cartographer/tests/integration/runnable/runnable_test.go:37
Latest stampedObject is the status
/Users/vmware/workspace/cartographer/tests/integration/runnable/runnable_test.go:710
populates the runnable.Status.outputs properly [It]
/Users/vmware/workspace/cartographer/tests/integration/runnable/runnable_test.go:745
Timed out after 1.000s.
Expected
<string>: RunnableStatus <<< #### this should be the struct ####
to match fields: {
.Conditions:
Expected
<[]v1.Condition | len:3, cap:4>: [
{
Type: "RunTemplateReady",
Status: "True",
ObservedGeneration: 0,
LastTransitionTime: {
Time: 2022-06-14T10:45:39-04:00,
},
Reason: "Ready",
Message: "",
},
{
Type: "StampedObjectReady",
Status: "Unknown",
ObservedGeneration: 0,
LastTransitionTime: {
Time: 2022-06-14T10:45:39-04:00,
},
Reason: "StampedObjectStatusAbsent",
Message: "",
},
{
Type: "Ready",
Status: "Unknown",
ObservedGeneration: 0,
LastTransitionTime: {
Time: 2022-06-14T10:45:39-04:00,
},
Reason: "StampedObjectStatusAbsent",
Message: "",
},
]
to contain elements
<[]*gstruct.FieldsMatcher | len:3, cap:3>: [
{
Fields: {
"Type": <*matchers.EqualMatcher | 0xc000537ad0>{
Expected: <string>"Ready",
},
"Status": <*matchers.EqualMatcher | 0xc000537ae0>{
Expected: <v1.ConditionStatus>"False",
},
},
IgnoreExtras: true,
IgnoreMissing: false,
failures: [
<*errors.NestedError | 0xc000ae5380>{
Path: ".Status",
Err: <*errors.errorString | 0xc0005377b0>{
s: "Expected\n <v1.ConditionStatus>: Unknown\nto equal\n <v1.ConditionStatus>: False",
},
},
],
},
{
Fields: {
"Type": <*matchers.EqualMatcher | 0xc000537af0>{
Expected: <string>"StampedObjectReady",
},
"Status": <*matchers.EqualMatcher | 0xc000537b00>{
Expected: <v1.ConditionStatus>"False",
},
},
IgnoreExtras: true,
IgnoreMissing: false,
failures: [
<*errors.NestedError | 0xc000ae53a0>{
Path: ".Type",
Err: <*errors.errorString | 0xc0005378e0>{
s: "Expected\n <string>: Ready\nto equal\n <string>: StampedObjectReady",
},
},
<*errors.NestedError | 0xc000ae53c0>{
Path: ".Status",
Err: <*errors.errorString | 0xc0005379d0>{
s: "Expected\n <v1.ConditionStatus>: Unknown\nto equal\n <v1.ConditionStatus>: False",
},
},
],
},
{
Fields: {
"Type": <*matchers.EqualMatcher | 0xc000537b10>{
Expected: <string>"RunTemplateReady",
},
"Status": <*matchers.EqualMatcher | 0xc000537b20>{
Expected: <v1.ConditionStatus>"True",
},
},
IgnoreExtras: true,
IgnoreMissing: false,
failures: [
<*errors.NestedError | 0xc000ae5400>{
Path: ".Type",
Err: <*errors.errorString | 0xc000537c50>{
s: "Expected\n <string>: Ready\nto equal\n <string>: RunTemplateReady",
},
},
<*errors.NestedError | 0xc000ae5420>{
Path: ".Status",
Err: <*errors.errorString | 0xc000537d40>{
s: "Expected\n <v1.ConditionStatus>: Unknown\nto equal\n <v1.ConditionStatus>: True",
},
},
],
},
]
the missing elements were
<[]*gstruct.FieldsMatcher | len:2, cap:2>: [
{
Fields: {
"Type": <*matchers.EqualMatcher | 0xc000537ad0>{
Expected: <string>"Ready",
},
"Status": <*matchers.EqualMatcher | 0xc000537ae0>{
Expected: <v1.ConditionStatus>"False",
},
},
IgnoreExtras: true,
IgnoreMissing: false,
failures: [
<*errors.NestedError | 0xc000ae5380>{
Path: ".Status",
Err: <*errors.errorString | 0xc0005377b0>{
s: "Expected\n <v1.ConditionStatus>: Unknown\nto equal\n <v1.ConditionStatus>: False",
},
},
],
},
{
Fields: {
"Status": <*matchers.EqualMatcher | 0xc000537b00>{
Expected: <v1.ConditionStatus>"False",
},
"Type": <*matchers.EqualMatcher | 0xc000537af0>{
Expected: <string>"StampedObjectReady",
},
},
IgnoreExtras: true,
IgnoreMissing: false,
failures: [
<*errors.NestedError | 0xc000ae53a0>{
Path: ".Type",
Err: <*errors.errorString | 0xc0005378e0>{
s: "Expected\n <string>: Ready\nto equal\n <string>: StampedObjectReady",
},
},
<*errors.NestedError | 0xc000ae53c0>{
Path: ".Status",
Err: <*errors.errorString | 0xc0005379d0>{
s: "Expected\n <v1.ConditionStatus>: Unknown\nto equal\n <v1.ConditionStatus>: False",
},
},
],
},
]
}
/Users/vmware/workspace/cartographer/tests/integration/runnable/runnable_test.go:847