Skip to content

Commit

Permalink
fix for failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
koba1t committed Jan 8, 2024
1 parent 17d5c26 commit 594aaee
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 34 deletions.
16 changes: 8 additions & 8 deletions api/krusty/complexcomposition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ apiVersion: builtin
kind: PatchTransformer
metadata:
name: svcNameTran
target:
target:
group: apps
version: v1
kind: StatefulSet
Expand Down Expand Up @@ -153,7 +153,7 @@ apiVersion: builtin
kind: PatchTransformer
metadata:
name: envFromConfigTrans
target:
target:
group: apps
version: v1
kind: StatefulSet
Expand Down Expand Up @@ -213,7 +213,7 @@ apiVersion: builtin
kind: PatchTransformer
metadata:
name: tolTrans
target:
target:
group: apps
version: v1
kind: StatefulSet
Expand Down Expand Up @@ -264,7 +264,7 @@ apiVersion: builtin
kind: PatchTransformer
metadata:
name: storageTrans
target:
target:
group: apps
version: v1
kind: StatefulSet
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
}
Expand Down
27 changes: 5 additions & 22 deletions api/krusty/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -391,9 +392,6 @@ resources:
nameSuffix: "-a"
`),
writeC("comp-b", `
resources:
- ../base
nameSuffix: "-b"
`),
writeK("prod", `
Expand All @@ -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
`,
},

Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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`,
},
}

Expand Down
6 changes: 3 additions & 3 deletions api/krusty/remoteloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -176,7 +176,7 @@ resources:
{
name: "has ref",
kustomization: `
resources:
resources:
- "file://$ROOT/simple.git?ref=change-image"
`,

Expand Down Expand Up @@ -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,
},
}
Expand Down
2 changes: 1 addition & 1 deletion api/resmap/resmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 594aaee

Please sign in to comment.