MCPcopy Create free account
hub / github.com/docker/secrets-engine / Test_logFilePrefix

Function Test_logFilePrefix

x/logging/logging_test.go:25–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func Test_logFilePrefix(t *testing.T) {
26 t.Parallel()
27 t.Run("printf", func(t *testing.T) {
28 buf := &bytes.Buffer{}
29 logger := &defaultLogger{logger: log.New(buf, "", log.LstdFlags), prefix: "prefix"}
30 logger.Printf("foo")
31 result := buf.String()
32 assert.NotContains(t, result, "logging.go")
33 assert.Contains(t, result, "logging_test.go")
34 })
35 t.Run("warnf", func(t *testing.T) {
36 buf := &bytes.Buffer{}
37 logger := &defaultLogger{logger: log.New(buf, "", log.LstdFlags), prefix: "prefix"}
38 logger.Warnf("foo")
39 result := buf.String()
40 assert.NotContains(t, result, "logging.go")
41 assert.Contains(t, result, "logging_test.go")
42 })
43 t.Run("errorf", func(t *testing.T) {
44 buf := &bytes.Buffer{}
45 logger := &defaultLogger{logger: log.New(buf, "", log.LstdFlags), prefix: "prefix"}
46 logger.Errorf("foo")
47 result := buf.String()
48 assert.NotContains(t, result, "logging.go")
49 assert.Contains(t, result, "logging_test.go")
50 })
51}

Callers

nothing calls this directly

Calls 5

PrintfMethod · 0.95
WarnfMethod · 0.95
ErrorfMethod · 0.95
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected