| 1032 | } |
| 1033 | |
| 1034 | func TestFatalDisabled(t *testing.T) { |
| 1035 | out := &bytes.Buffer{} |
| 1036 | log := New(out).Level(PanicLevel) // Disable FatalLevel |
| 1037 | |
| 1038 | // Set FatalExitFunc to set a flag |
| 1039 | var fatalCalled bool |
| 1040 | oldFatalExitFunc := FatalExitFunc |
| 1041 | FatalExitFunc = func() { fatalCalled = true } |
| 1042 | defer func() { FatalExitFunc = oldFatalExitFunc }() |
| 1043 | |
| 1044 | // Call Fatal, which should be disabled, call done, and return nil |
| 1045 | e := log.Fatal() |
| 1046 | if e != nil { |
| 1047 | t.Error("Expected nil event when Fatal is disabled") |
| 1048 | } |
| 1049 | if !fatalCalled { |
| 1050 | t.Error("Expected FatalExitFunc to be called when Fatal is disabled") |
| 1051 | } |
| 1052 | if out.Len() > 0 { |
| 1053 | t.Errorf("Expected no output when Fatal is disabled, got: %s", out.String()) |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | func TestPanicDisabled(t *testing.T) { |
| 1058 | out := &bytes.Buffer{} |