Skip to content

Commit

Permalink
fix: Make pkg/action/action_test.go.with*() composable
Browse files Browse the repository at this point in the history
Signed-off-by: Víctor Cuadrado Juan <[email protected]>
  • Loading branch information
viccuad committed Mar 10, 2021
1 parent aa80681 commit 0ba6417
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
16 changes: 8 additions & 8 deletions pkg/action/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ func buildChart(opts ...chartOption) *chart.Chart {

func withHypperAnnotations() chartOption {
return func(opts *chartOptions) {
opts.Chart.Metadata.Annotations = map[string]string{
"hypper.cattle.io/namespace": "hypper",
"hypper.cattle.io/release-name": "my-hypper-name",
"catalog.cattle.io/namespace": "fleet-system",
"catalog.cattle.io/release-name": "fleet",
if opts.Chart.Metadata.Annotations == nil {
opts.Chart.Metadata.Annotations = make(map[string]string)
}
opts.Chart.Metadata.Annotations["hypper.cattle.io/namespace"] = "hypper"
opts.Chart.Metadata.Annotations["hypper.cattle.io/release-name"] = "my-hypper-name"
}
}

func withFallbackAnnotations() chartOption {
return func(opts *chartOptions) {
opts.Chart.Metadata.Annotations = map[string]string{
"catalog.cattle.io/namespace": "fleet-system",
"catalog.cattle.io/release-name": "fleet",
if opts.Chart.Metadata.Annotations == nil {
opts.Chart.Metadata.Annotations = make(map[string]string)
}
opts.Chart.Metadata.Annotations["catalog.cattle.io/namespace"] = "fleet-system"
opts.Chart.Metadata.Annotations["catalog.cattle.io/release-name"] = "fleet"
}
}
4 changes: 2 additions & 2 deletions pkg/action/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestSetNamespace(t *testing.T) {

// hypper annotations have priority over fallback annotations
instAction = installAction(t)
chart = buildChart(withHypperAnnotations())
chart = buildChart(withHypperAnnotations(), withFallbackAnnotations())
instAction.SetNamespace(chart, "defaultns")
is.Equal("hypper", instAction.Namespace)

Expand Down Expand Up @@ -78,7 +78,7 @@ func TestName(t *testing.T) {

// hypper annotations have priority over fallback annotations
instAction = installAction(t)
chart = buildChart(withHypperAnnotations())
chart = buildChart(withHypperAnnotations(), withFallbackAnnotations())
name, err = instAction.Name(chart, []string{"chart-uri"})
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 0ba6417

Please sign in to comment.