...
1
2
3
4
19
20 package logging
21
22
23
24
25
26 import (
27 "testing"
28
29 "k8s.io/kubernetes/test/utils/ktesting"
30 )
31
32 func TestError(t *testing.T) {
33 tCtx := ktesting.Init(t)
34 tCtx.Error("some", "thing")
35 }
36
37 func TestErrorf(t *testing.T) {
38 tCtx := ktesting.Init(t)
39 tCtx.Errorf("some %s", "thing")
40 }
41
42 func TestFatal(t *testing.T) {
43 tCtx := ktesting.Init(t)
44 tCtx.Fatal("some", "thing")
45 tCtx.Log("not reached")
46 }
47
48 func TestFatalf(t *testing.T) {
49 tCtx := ktesting.Init(t)
50 tCtx.Fatalf("some %s", "thing")
51 tCtx.Log("not reached")
52 }
53
54 func TestInfo(t *testing.T) {
55 tCtx := ktesting.Init(t)
56 tCtx.Log("hello via Log")
57 tCtx.Logger().Info("hello via Info")
58 tCtx.Error("some", "thing")
59 }
60
61 func TestWithStep(t *testing.T) {
62 tCtx := ktesting.Init(t)
63 bake(ktesting.WithStep(tCtx, "bake cake"))
64 }
65
66 func bake(tCtx ktesting.TContext) {
67 heatOven(ktesting.WithStep(tCtx, "set heat for baking"))
68 }
69
70 func heatOven(tCtx ktesting.TContext) {
71 tCtx.Log("Log()")
72 tCtx.Logger().Info("Logger().Info()")
73 tCtx.Fatal("oven not found")
74 }
75
View as plain text