From b3b7bfd9957d8c6d3a6a94e0d9bd7f89c0fb3995 Mon Sep 17 00:00:00 2001 From: Hongchao Deng Date: Mon, 28 Sep 2020 14:46:42 -0700 Subject: [PATCH] fix test Signed-off-by: Hongchao Deng --- .../applicationconfiguration_test.go | 5 +++-- pkg/controller/v1alpha2/applicationconfiguration/render.go | 2 +- .../v1alpha2/applicationconfiguration/render_test.go | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pkg/controller/v1alpha2/applicationconfiguration/applicationconfiguration_test.go b/pkg/controller/v1alpha2/applicationconfiguration/applicationconfiguration_test.go index b7461f8d..7b5c8a48 100644 --- a/pkg/controller/v1alpha2/applicationconfiguration/applicationconfiguration_test.go +++ b/pkg/controller/v1alpha2/applicationconfiguration/applicationconfiguration_test.go @@ -1333,8 +1333,9 @@ func TestDependency(t *testing.T) { ac := &v1alpha2.ApplicationConfiguration{ ObjectMeta: metav1.ObjectMeta{ - Name: "test-app", - Namespace: "test-ns", + Name: "test-app", + Namespace: "test-ns", + Generation: 0, }, Spec: v1alpha2.ApplicationConfigurationSpec{ Components: tc.args.components, diff --git a/pkg/controller/v1alpha2/applicationconfiguration/render.go b/pkg/controller/v1alpha2/applicationconfiguration/render.go index c76cfa3f..1e79e282 100644 --- a/pkg/controller/v1alpha2/applicationconfiguration/render.go +++ b/pkg/controller/v1alpha2/applicationconfiguration/render.go @@ -502,7 +502,7 @@ func (r *components) getDataInput(ctx context.Context, s *dagSource, ac *unstruc pavedAC := fieldpath.Pave(ac.UnstructuredContent()) var acGeneration int - if err := pavedAC.GetValueInto("metadata.generation", &acGeneration); err != nil { + if err := pavedAC.GetValueInto("metadata.generation", &acGeneration); err != nil && !fieldpath.IsNotFound(err) { return nil, false, err.Error(), err } diff --git a/pkg/controller/v1alpha2/applicationconfiguration/render_test.go b/pkg/controller/v1alpha2/applicationconfiguration/render_test.go index 9437e29e..d8d3e4b4 100644 --- a/pkg/controller/v1alpha2/applicationconfiguration/render_test.go +++ b/pkg/controller/v1alpha2/applicationconfiguration/render_test.go @@ -200,6 +200,7 @@ func TestRenderComponents(t *testing.T) { oam.LabelAppName: acName, oam.LabelAppComponentRevision: "", oam.LabelOAMResourceType: oam.ResourceTypeWorkload, + oam.LabelAppGeneration: "0", }) return w }(), @@ -214,6 +215,7 @@ func TestRenderComponents(t *testing.T) { oam.LabelAppName: acName, oam.LabelAppComponentRevision: "", oam.LabelOAMResourceType: oam.ResourceTypeTrait, + oam.LabelAppGeneration: "0", }) return &Trait{Object: *t} }(), @@ -275,6 +277,7 @@ func TestRenderComponents(t *testing.T) { oam.LabelAppName: acName, oam.LabelAppComponentRevision: revisionName, oam.LabelOAMResourceType: oam.ResourceTypeWorkload, + oam.LabelAppGeneration: "0", }) return w }(), @@ -289,6 +292,7 @@ func TestRenderComponents(t *testing.T) { oam.LabelAppName: acName, oam.LabelAppComponentRevision: revisionName, oam.LabelOAMResourceType: oam.ResourceTypeTrait, + oam.LabelAppGeneration: "0", }) return &Trait{Object: *t} }(), @@ -341,6 +345,7 @@ func TestRenderComponents(t *testing.T) { oam.LabelAppName: acName, oam.LabelAppComponentRevision: revisionName2, oam.LabelOAMResourceType: oam.ResourceTypeWorkload, + oam.LabelAppGeneration: "0", }) return w }(), @@ -355,6 +360,7 @@ func TestRenderComponents(t *testing.T) { oam.LabelAppName: acName, oam.LabelAppComponentRevision: revisionName2, oam.LabelOAMResourceType: oam.ResourceTypeTrait, + oam.LabelAppGeneration: "0", }) return &Trait{Object: *t} }(),