fix TestBarPanics
Vladimir Bauer
8 years ago
| 87 | 87 | func TestBarPanics(t *testing.T) { |
| 88 | 88 | var wg sync.WaitGroup |
| 89 | 89 | var buf bytes.Buffer |
| 90 | p := New(WithOutput(&buf), WithWaitGroup(&wg)) | |
| 90 | p := New(WithDebugOutput(&buf), WithOutput(nil), WithWaitGroup(&wg)) | |
| 91 | 91 | |
| 92 | 92 | wantPanic := "Upps!!!" |
| 93 | 93 | numBars := 1 |
| 116 | 116 | p.Wait() |
| 117 | 117 | |
| 118 | 118 | wantPanic = fmt.Sprintf("panic: %s", wantPanic) |
| 119 | lastLine := getLastLine(buf.Bytes()) | |
| 120 | 119 | |
| 121 | if string(lastLine) != wantPanic { | |
| 122 | t.Errorf("Want: %q, got: %q\n", wantPanic, string(lastLine)) | |
| 120 | debugStr := buf.String() | |
| 121 | if !strings.Contains(debugStr, wantPanic) { | |
| 122 | t.Errorf("%q doesn't contain %q\n", debugStr, wantPanic) | |
| 123 | 123 | } |
| 124 | 124 | } |