Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/e2e: fix skipRootUserTests flag 🎏 #2304

Merged
merged 1 commit into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ import (
)

var initMetrics sync.Once
var skipRootUserTests = false

func init() {
flag.BoolVar(&skipRootUserTests, "skipRootUserTests", false, "Skip tests that require root user")
}

func setup(t *testing.T, fn ...func(*testing.T, *clients, string)) (*clients, string) {
t.Helper()
Expand Down Expand Up @@ -146,6 +151,7 @@ func verifyServiceAccountExistence(t *testing.T, namespace string, kubeClient *k
// TestMain initializes anything global needed by the tests. Right now this is just log and metric
// setup since the log and metric libs we're using use global state :(
func TestMain(m *testing.M) {
flag.Parse()
c := m.Run()
fmt.Fprintf(os.Stderr, "Using kubeconfig at `%s` with cluster `%s`\n", knativetest.Flags.Kubeconfig, knativetest.Flags.Cluster)
os.Exit(c)
Expand Down
11 changes: 1 addition & 10 deletions test/kaniko_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ limitations under the License.
package test

import (
"flag"
"fmt"
"strings"
"testing"
Expand All @@ -44,17 +43,9 @@ const (
revision = "1c9d566ecd13535f93789595740f20932f655905"
)

var (
skipRootUserTests = "false"
)

func init() {
flag.StringVar(&skipRootUserTests, "skipRootUserTests", "false", "Skip tests that require root user")
}

// TestTaskRun is an integration test that will verify a TaskRun using kaniko
func TestKanikoTaskRun(t *testing.T) {
if skipRootUserTests == "true" {
if skipRootUserTests {
t.Skip("Skip test as skipRootUserTests set to true")
}

Expand Down
6 changes: 6 additions & 0 deletions test/v1alpha1/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ import (
)

var initMetrics sync.Once
var skipRootUserTests = false

func init() {
flag.BoolVar(&skipRootUserTests, "skipRootUserTests", false, "Skip tests that require root user")
}

func setup(t *testing.T, fn ...func(*testing.T, *clients, string)) (*clients, string) {
t.Helper()
Expand Down Expand Up @@ -146,6 +151,7 @@ func verifyServiceAccountExistence(t *testing.T, namespace string, kubeClient *k
// TestMain initializes anything global needed by the tests. Right now this is just log and metric
// setup since the log and metric libs we're using use global state :(
func TestMain(m *testing.M) {
flag.Parse()
c := m.Run()
fmt.Fprintf(os.Stderr, "Using kubeconfig at `%s` with cluster `%s`\n", knativetest.Flags.Kubeconfig, knativetest.Flags.Cluster)
os.Exit(c)
Expand Down
6 changes: 1 addition & 5 deletions test/v1alpha1/kaniko_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ const (
revision = "1c9d566ecd13535f93789595740f20932f655905"
)

var (
skipRootUserTests = "false"
)

// TestTaskRun is an integration test that will verify a TaskRun using kaniko
func TestKanikoTaskRun(t *testing.T) {
if skipRootUserTests == "true" {
if skipRootUserTests {
t.Skip("Skip test as skipRootUserTests set to true")
}

Expand Down