Skip to content

Commit

Permalink
Add env to distinguish type of cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
matrus2 committed Jun 27, 2022
1 parent daf1681 commit 31960c4
Showing 1 changed file with 25 additions and 9 deletions.
34 changes: 25 additions & 9 deletions examples/real_cluster/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,31 @@ var testenv env.Environment

func TestMain(m *testing.M) {
testenv = env.New()
path := conf.ResolveKubeConfigFile()
cfg := envconf.NewWithKubeConfig(path)
testenv = env.NewWithConfig(cfg)
namespace := envconf.RandomName("sample-ns", 16)
testenv.Setup(
envfuncs.CreateNamespace(namespace),
)
testenv.Finish(
envfuncs.DeleteNamespace(namespace),
)
if os.Getenv("REAL_CLUSTER") == "true" {
path := conf.ResolveKubeConfigFile()
cfg := envconf.NewWithKubeConfig(path)
testenv = env.NewWithConfig(cfg)

testenv.Setup(
envfuncs.CreateNamespace(namespace),
)
testenv.Finish(
envfuncs.DeleteNamespace(namespace),
)
} else {
kindClusterName := envconf.RandomName("kind-with-config", 16)

testenv.Setup(
envfuncs.CreateKindCluster(kindClusterName),
envfuncs.CreateNamespace(namespace),
)

testenv.Finish(
envfuncs.DeleteNamespace(namespace),
envfuncs.DestroyKindCluster(kindClusterName),
)
}

os.Exit(testenv.Run(m))
}

0 comments on commit 31960c4

Please sign in to comment.