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

Commit

Permalink
test/components: use NewConfig() instead of components.Get()
Browse files Browse the repository at this point in the history
So no globals or HCL parsing is involved in testing. Also
components.Get() is now deprecated, as we want to avoid relying on
globals and init() functions.

Part of #992

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
  • Loading branch information
invidian committed Dec 2, 2020
1 parent 2c4e78b commit eca49ea
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
10 changes: 2 additions & 8 deletions test/components/component_delete_multiple_release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,13 @@ package components_test
import (
"testing"

"github.com/kinvolk/lokomotive/pkg/components"
"github.com/kinvolk/lokomotive/pkg/components/util"
_ "github.com/kinvolk/lokomotive/pkg/components/web-ui"
webui "github.com/kinvolk/lokomotive/pkg/components/web-ui"
testutil "github.com/kinvolk/lokomotive/test/components/util"
)

func TestDeleteNamespaceMultipleRelease(t *testing.T) {
n := "web-ui"

c, err := components.Get(n)
if err != nil {
t.Fatalf("failed getting component: %v", err)
}
c := webui.NewConfig()

k := testutil.Kubeconfig(t)

Expand Down
26 changes: 2 additions & 24 deletions test/components/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,13 @@ package components
import (
"testing"

"github.com/hashicorp/hcl/v2"

"github.com/kinvolk/lokomotive/pkg/components"
_ "github.com/kinvolk/lokomotive/pkg/components/flatcar-linux-update-operator"
fluo "github.com/kinvolk/lokomotive/pkg/components/flatcar-linux-update-operator"
"github.com/kinvolk/lokomotive/pkg/components/util"
testutil "github.com/kinvolk/lokomotive/test/components/util"
)

func TestInstallIdempotent(t *testing.T) {
configHCL := `
component "flatcar-linux-update-operator" {}
`

n := "flatcar-linux-update-operator"

c, err := components.Get(n)
if err != nil {
t.Fatalf("failed getting component: %v", err)
}

body, diagnostics := util.GetComponentBody(configHCL, n)
if diagnostics != nil {
t.Fatalf("Error getting component body: %v", diagnostics)
}

diagnostics = c.LoadConfig(body, &hcl.EvalContext{})
if diagnostics.HasErrors() {
t.Fatalf("Valid config should not return error, got: %s", diagnostics)
}
c := fluo.NewConfig()

k := testutil.Kubeconfig(t)

Expand Down

0 comments on commit eca49ea

Please sign in to comment.