Skip to content

Commit

Permalink
Merge pull request #305 from pohly/flush-and-exit
Browse files Browse the repository at this point in the history
remove side effects of tests
  • Loading branch information
k8s-ci-robot committed Mar 15, 2022
2 parents 6631b8c + cd54fdc commit ae0c078
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions contextual_test.go
Expand Up @@ -24,6 +24,8 @@ import (
)

func ExampleSetLogger() {
defer klog.ClearLogger()

// Logger is only used as backend, Background() returns klogr.
klog.SetLogger(logr.Discard())
fmt.Printf("logger after SetLogger: %T\n", klog.Background().GetSink())
Expand Down
3 changes: 3 additions & 0 deletions exit_test.go
Expand Up @@ -24,10 +24,13 @@ import (

func ExampleFlushAndExit() {
// Set up klog so that we can test it below.

var fs flag.FlagSet
klog.InitFlags(&fs)
fs.Set("skip_headers", "true")
defer flag.Set("skip_headers", "false")
fs.Set("logtostderr", "false")
defer fs.Set("logtostderr", "true")
klog.SetOutput(os.Stdout)
defer klog.SetOutput(nil)
klog.OsExit = func(exitCode int) {
Expand Down

0 comments on commit ae0c078

Please sign in to comment.