Skip to content

Commit 74a0ce7

Browse files
committed
fixed unit tests
- reset CommandLine flagSet before calling klog.InitFlags(nil) to avoid conflicts if an imported package already called it.
1 parent 4b03634 commit 74a0ce7

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

test/helpers/envtest.go

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package helpers
1818

1919
import (
2020
"context"
21+
"flag"
2122
"fmt"
2223
"go/build"
2324
"net"
@@ -65,6 +66,8 @@ var (
6566
)
6667

6768
func init() {
69+
// reset flags to avoid conflicts if an imported package already called klog.InitFlags()
70+
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError)
6871
klog.InitFlags(nil)
6972
// additionally force all the controllers to use the Ginkgo logger.
7073
ctrl.SetLogger(klog.Background())

0 commit comments

Comments
 (0)