(t *testing.T)
| 145 | } |
| 146 | |
| 147 | func TestCappedStringWriter(t *testing.T) { |
| 148 | t.Run("captures full output under limit", func(t *testing.T) { |
| 149 | w := newCappedStringWriter(8) |
| 150 | n, err := w.Write([]byte("hello")) |
| 151 | if err != nil { |
| 152 | t.Fatalf("unexpected error: %v", err) |
| 153 | } |
| 154 | if n != 5 { |
| 155 | t.Fatalf("expected 5 bytes written, got %d", n) |
| 156 | } |
| 157 | if got := w.String(); got != "hello" { |
| 158 | t.Fatalf("expected %q, got %q", "hello", got) |
| 159 | } |
| 160 | if w.Truncated() { |
| 161 | t.Fatal("expected writer not truncated") |
| 162 | } |
| 163 | }) |
| 164 | |
| 165 | t.Run("caps output and marks truncated", func(t *testing.T) { |
| 166 | w := newCappedStringWriter(4) |
| 167 | n, err := w.Write([]byte("helloworld")) |
| 168 | if err != nil { |
| 169 | t.Fatalf("unexpected error: %v", err) |
| 170 | } |
| 171 | if n != len("helloworld") { |
| 172 | t.Fatalf("expected write count %d, got %d", len("helloworld"), n) |
| 173 | } |
| 174 | if got := w.String(); got != "hell" { |
| 175 | t.Fatalf("expected %q, got %q", "hell", got) |
| 176 | } |
| 177 | if !w.Truncated() { |
| 178 | t.Fatal("expected writer to be truncated") |
| 179 | } |
| 180 | }) |
| 181 | } |
| 182 | |
| 183 | func TestHookTimeoutFromEnv(t *testing.T) { |
| 184 | tests := []struct { |
nothing calls this directly
no test coverage detected