-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
Description of problem
When setting the Expect inline -
Expect: cartotesting.TemplateTestExpectation{
ExpectedObject: &v1alpha2.Image{
TypeMeta: metav1.TypeMeta{
Kind: "Image",
APIVersion: "kpack.io/v1alpha2",
},
ObjectMeta: metav1.ObjectMeta{},
Spec: v1alpha2.ImageSpec{
Tag: "my-server/my-repo/my-workload-my-ns",
ServiceAccountName: "default",
Builder: corev1.ObjectReference{
Kind: "ClusterBuilder",
Name: "default",
},
Source: v1alpha12.SourceConfig{
Blob: &v1alpha12.Blob{
URL: "my-url",
},
},
Build: &v1alpha2.ImageBuild{
Env: []corev1.EnvVar{
{
Name: "BP_OCI_SOURCE",
Value: "my-rev",
},
},
Services: v1alpha2.Services{},
},
},
Status: v1alpha2.ImageStatus{},
},
},
The test will fail with -
templates.go:87: expected does not equal actual: (-expected +actual):
map[string]any{
"apiVersion": string("kpack.io/v1alpha2"),
"kind": string("Image"),
"spec": map[string]any{
"build": map[string]any{
"env": []any{map[string]any{"name": string("BP_OCI_SOURCE"), "value": string("my-rev")}},
- "resources": map[string]any{},
+ "services": []any{},
},
I would have expected the test to succeed.
Proposed solution
- Figure out how to coerce kpack Image (and other CRDs) with empty values
- Add an ignore fields option to the test where we can omit resources and services in this example
- Use ExpectedFile instead of ExpectedObject (workaround) - it works
- Use ExpectedUnstructured instead of ExpectObject (another workaround) - it works
Example
<Code snippets that illustrate the when/then blocks>
Additional Context
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels