MCPcopy
hub / github.com/op/go-logging / TestLevelModuleLevel

Function TestLevelModuleLevel

level_test.go:50–76  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

48}
49
50func TestLevelModuleLevel(t *testing.T) {
51 backend := NewMemoryBackend(128)
52
53 leveled := AddModuleLevel(backend)
54 leveled.SetLevel(NOTICE, "")
55 leveled.SetLevel(ERROR, "foo")
56 leveled.SetLevel(INFO, "foo.bar")
57 leveled.SetLevel(WARNING, "bar")
58
59 expected := []struct {
60 level Level
61 module string
62 }{
63 {NOTICE, ""},
64 {NOTICE, "something"},
65 {ERROR, "foo"},
66 {INFO, "foo.bar"},
67 {WARNING, "bar"},
68 }
69
70 for _, e := range expected {
71 actual := leveled.GetLevel(e.module)
72 if e.level != actual {
73 t.Errorf("unexpected level in %s: %s != %s", e.module, e.level, actual)
74 }
75 }
76}

Callers

nothing calls this directly

Calls 5

NewMemoryBackendFunction · 0.85
AddModuleLevelFunction · 0.85
ErrorfMethod · 0.80
SetLevelMethod · 0.65
GetLevelMethod · 0.65

Tested by

no test coverage detected