From 594aaee9569892d3c3511dd9179c7a251965c49c Mon Sep 17 00:00:00 2001 From: koba1t Date: Thu, 31 Aug 2023 17:00:53 +0900 Subject: [PATCH] fix for failing tests --- api/krusty/complexcomposition_test.go | 16 ++++++++-------- api/krusty/component_test.go | 27 +++++---------------------- api/krusty/remoteloader_test.go | 6 +++--- api/resmap/resmap.go | 2 +- 4 files changed, 17 insertions(+), 34 deletions(-) diff --git a/api/krusty/complexcomposition_test.go b/api/krusty/complexcomposition_test.go index 7c3dfc39fdb..553ffc833ef 100644 --- a/api/krusty/complexcomposition_test.go +++ b/api/krusty/complexcomposition_test.go @@ -81,7 +81,7 @@ apiVersion: builtin kind: PatchTransformer metadata: name: svcNameTran -target: +target: group: apps version: v1 kind: StatefulSet @@ -153,7 +153,7 @@ apiVersion: builtin kind: PatchTransformer metadata: name: envFromConfigTrans -target: +target: group: apps version: v1 kind: StatefulSet @@ -213,7 +213,7 @@ apiVersion: builtin kind: PatchTransformer metadata: name: tolTrans -target: +target: group: apps version: v1 kind: StatefulSet @@ -264,7 +264,7 @@ apiVersion: builtin kind: PatchTransformer metadata: name: storageTrans -target: +target: group: apps version: v1 kind: StatefulSet @@ -365,10 +365,10 @@ resources: `) err := th.RunWithErr("dev", th.MakeDefaultOptions()) if err == nil { - t.Fatalf("Expected resource accumulation error") + t.Fatalf("Expected resource accumulation error:\n%s\n", th.Run("dev", th.MakeDefaultOptions())) } - if !strings.Contains( - err.Error(), "already registered id: StatefulSet.v1.apps/my-sts.[noNs]") { + if !strings.Contains(err.Error(), + `resid.ResId{Gvk:resid.Gvk{Group:"apps", Version:"v1", Kind:"StatefulSet", isClusterScoped:false}, Name:"my-sts", Namespace:""} exists`) { t.Fatalf("Unexpected err: %v", err) } } @@ -459,7 +459,7 @@ resources: t.Fatalf("Expected resource accumulation error") } if !strings.Contains( - err.Error(), "already registered id: StatefulSet.v1.apps/my-sts.[noNs]") { + err.Error(), `id resid.ResId{Gvk:resid.Gvk{Group:"apps", Version:"v1", Kind:"StatefulSet", isClusterScoped:false}, Name:"my-sts", Namespace:""} exists`) { t.Fatalf("Unexpected err: %v", err) } } diff --git a/api/krusty/component_test.go b/api/krusty/component_test.go index f0965d923a2..db6b7e31366 100644 --- a/api/krusty/component_test.go +++ b/api/krusty/component_test.go @@ -380,7 +380,8 @@ spec: `, }, // See how nameSuffix "-b" is also added to the resources included by "comp-a" because they are in the - // accumulator when "comp-b" is accumulated. In practice we could use simple Kustomizations for this example. + // accumulator when "comp-b" is accumulated. + // In practice we could use simple Kustomizations for this example. "components-can-add-the-same-base-if-the-first-renames-resources": { input: []FileGen{writeTestBase, deployment("proxy", "comp-a/proxy.yaml"), @@ -391,9 +392,6 @@ resources: nameSuffix: "-a" `), writeC("comp-b", ` -resources: -- ../base - nameSuffix: "-b" `), writeK("prod", ` @@ -417,21 +415,6 @@ data: kind: ConfigMap metadata: name: my-configmap-a-b-9cd648hm8f ---- -apiVersion: v1 -kind: Deployment -metadata: - name: storefront-b -spec: - replicas: 1 ---- -apiVersion: v1 -data: - otherValue: green - testValue: purple -kind: ConfigMap -metadata: - name: my-configmap-b-9cd648hm8f `, }, @@ -590,7 +573,7 @@ components: - ../comp-b`), }, runPath: "prod", - expectedError: "may not add resource with an already registered id: Deployment.v1.[noGrp]/proxy.[noNs]", + expectedError: `id resid.ResId{Gvk:resid.Gvk{Group:\"\", Version:\"v1\", Kind:\"Deployment\", isClusterScoped:false}, Name:\"proxy\", Namespace:\"\"} exists`, }, "components-cannot-add-the-same-base": { input: []FileGen{writeTestBase, @@ -609,7 +592,7 @@ components: - ../comp-b`), }, runPath: "prod", - expectedError: "may not add resource with an already registered id: Deployment.v1.[noGrp]/storefront.[noNs]", + expectedError: `resid.ResId{Gvk:resid.Gvk{Group:\"\", Version:\"v1\", Kind:\"Deployment\", isClusterScoped:false}, Name:\"storefront\", Namespace:\"\"} exists`, }, "components-cannot-add-bases-containing-the-same-resource": { input: []FileGen{writeTestBase, @@ -640,7 +623,7 @@ components: - ../comp-b`), }, runPath: "prod", - expectedError: "may not add resource with an already registered id: Deployment.v1.[noGrp]/proxy.[noNs]", + expectedError: `resid.ResId{Gvk:resid.Gvk{Group:\"\", Version:\"v1\", Kind:\"Deployment\", isClusterScoped:false}, Name:\"proxy\", Namespace:\"\"} exists`, }, } diff --git a/api/krusty/remoteloader_test.go b/api/krusty/remoteloader_test.go index b38b5789808..170c429ace8 100644 --- a/api/krusty/remoteloader_test.go +++ b/api/krusty/remoteloader_test.go @@ -105,7 +105,7 @@ cp -r $ROOT/simple.git/. $ROOT/$HASH_DIR git commit -m "relative submodule" git checkout main git submodule add $ROOT/simple.git submodule - git commit -m "submodule" + git commit -m "submodule" ) `, root, hashDir)) return testRepos{ @@ -176,7 +176,7 @@ resources: { name: "has ref", kustomization: ` -resources: +resources: - "file://$ROOT/simple.git?ref=change-image" `, @@ -383,7 +383,7 @@ resources: resources: - https://github.com/thisisa404.yaml `, - err: "accumulating resources: accumulating resources from 'https://github.com/thisisa404.yaml': HTTP Error: status code 404 (Not Found)", + err: `accumulating resources from 'https://github.com/thisisa404.yaml': HTTP Error: status code 404 (Not Found)`, errT: loader.ErrHTTP, }, } diff --git a/api/resmap/resmap.go b/api/resmap/resmap.go index c52190fea67..101cf32650b 100644 --- a/api/resmap/resmap.go +++ b/api/resmap/resmap.go @@ -83,7 +83,7 @@ type KustTargetInterface interface { func (c *PluginHelpers) AccumulateResource(path string) (ResMap, error) { resmap, err := c.kt.AccumulateResource(path) if err != nil { - return nil, fmt.Errorf("failed to AccumulateResource in internal `target` pkg: %w", err) + return nil, fmt.Errorf("failed to AccumulateResource in internal 'target' pkg: %w", err) } return resmap, nil }