Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
metallb: Divide helper function to return config
Browse files Browse the repository at this point in the history
This commit divides the functionality of `testRenderManifest` that
generates yaml files into a separate function `renderManifest`. This
will be helpful in subsequent test additions.

Signed-off-by: Suraj Deshmukh <suraj@kinvolk.io>
  • Loading branch information
surajssd committed Sep 9, 2020
1 parent d98d857 commit f4eaad4
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/components/metallb/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestEmptyConfig(t *testing.T) {
}
}

func testRenderManifest(t *testing.T, configHCL string) {
func renderManifest(t *testing.T, configHCL string) map[string]string {
component := newComponent()

body, diagnostics := util.GetComponentBody(configHCL, name)
Expand All @@ -45,11 +45,17 @@ func testRenderManifest(t *testing.T, configHCL string) {
t.Fatalf("Valid config should not return error, got: %s", diagnostics)
}

m, err := component.RenderManifests()
ret, err := component.RenderManifests()
if err != nil {
t.Fatalf("Rendering manifests with valid config should succeed, got: %s", err)
}
if len(m) <= 0 {

return ret
}

func testRenderManifest(t *testing.T, configHCL string) {
m := renderManifest(t, configHCL)
if len(m) == 0 {
t.Fatalf("Rendered manifests shouldn't be empty")
}
}
Expand Down

0 comments on commit f4eaad4

Please sign in to comment.