(t *testing.T)
| 81 | } |
| 82 | |
| 83 | func TestTestLoggerSupportsWrappedZapOptions(t *testing.T) { |
| 84 | ts := newTestLogSpy(t) |
| 85 | defer ts.AssertPassed() |
| 86 | |
| 87 | log := NewLogger(ts, WrapOptions(zap.AddCaller(), zap.Fields(zap.String("k1", "v1")))) |
| 88 | |
| 89 | log.Info("received work order") |
| 90 | log.Debug("starting work") |
| 91 | log.Warn("work may fail") |
| 92 | log.Error("work failed", zap.Error(errors.New("great sadness"))) |
| 93 | |
| 94 | assert.Panics(t, func() { |
| 95 | log.Panic("failed to do work") |
| 96 | }, "log.Panic should panic") |
| 97 | |
| 98 | ts.AssertMessages( |
| 99 | `INFO zaptest/logger_test.go:89 received work order {"k1": "v1"}`, |
| 100 | `DEBUG zaptest/logger_test.go:90 starting work {"k1": "v1"}`, |
| 101 | `WARN zaptest/logger_test.go:91 work may fail {"k1": "v1"}`, |
| 102 | `ERROR zaptest/logger_test.go:92 work failed {"k1": "v1", "error": "great sadness"}`, |
| 103 | `PANIC zaptest/logger_test.go:95 failed to do work {"k1": "v1"}`, |
| 104 | ) |
| 105 | } |
| 106 | |
| 107 | func TestTestingWriter(t *testing.T) { |
| 108 | ts := newTestLogSpy(t) |
nothing calls this directly
no test coverage detected
searching dependent graphs…