Skip to content

Commit

Permalink
Multi Namespace Test Support
Browse files Browse the repository at this point in the history
Signed-off-by: Nitishkumar Singh <[email protected]>

updates for multi-namespaces

Signed-off-by: Nitishkumar Singh <[email protected]>

Replace Space from Namespaces Env variables

Signed-off-by: Nitishkumar Singh <[email protected]>

Reomve space from namespaces

Signed-off-by: Nitishkumar Singh <[email protected]>
  • Loading branch information
nitishkumar71 authored and LucasRoesler committed Apr 2, 2021
1 parent 2d4a282 commit 9d1270d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/main_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package tests

import (
"encoding/json"
"flag"
"fmt"
"log"
Expand Down Expand Up @@ -37,6 +38,8 @@ func init() {
)
flag.BoolVar(&config.SecretUpdate, "secretUpdate", true, "enable/disable secret update tests")
flag.BoolVar(&config.ScaleToZero, "scaleToZero", true, "enable/disable scale from zero tests")

FromEnv(&config)
}

func TestMain(m *testing.M) {
Expand Down Expand Up @@ -70,6 +73,12 @@ func TestMain(m *testing.M) {
timeout := 5 * time.Second
config.Client = sdk.NewClient(config.Auth, config.Gateway, nil, &timeout)

prettyConfig, err := json.MarshalIndent(config, "", "\t")
if err != nil {
log.Fatalf("Config Pretty Print Failed with %s", err)
}
log.Println(string(prettyConfig))

os.Exit(m.Run())
}

Expand All @@ -91,4 +100,18 @@ type Config struct {
SecretUpdate bool
// ScaleToZero enables/disables the scale from zero test
ScaleToZero bool

// Namespaces to verfiy OpenFaaS provider
Namespaces []string
}

func FromEnv(config *Config) {
// read CERTIFIER_NAMESPACES variable, parse as csv string
namespaces, present := os.LookupEnv("CERTIFIER_NAMESPACES")
if present {
config.Namespaces = strings.Split(namespaces, ",")
for index := range config.Namespaces {
config.Namespaces[index] = strings.TrimSpace(config.Namespaces[index])
}
}
}

0 comments on commit 9d1270d

Please sign in to comment.