(t *testing.T)
| 264 | } |
| 265 | |
| 266 | func TestProgressBarEdgeCases(t *testing.T) { |
| 267 | t.Run("current exceeds total", func(t *testing.T) { |
| 268 | bar := NewProgressBar(100) |
| 269 | output := bar.Update(150) |
| 270 | |
| 271 | assert.NotEmpty(t, output, "Should handle current exceeding total gracefully") |
| 272 | |
| 273 | // In non-TTY mode, percentage will be > 100 |
| 274 | if !isTTY() { |
| 275 | assert.Contains(t, output, "150%", "Should show percentage > 100") |
| 276 | } |
| 277 | }) |
| 278 | |
| 279 | t.Run("negative current value", func(t *testing.T) { |
| 280 | bar := NewProgressBar(100) |
| 281 | output := bar.Update(-10) |
| 282 | |
| 283 | assert.NotEmpty(t, output, "Should handle negative values gracefully") |
| 284 | }) |
| 285 | |
| 286 | t.Run("very small progress increments", func(t *testing.T) { |
| 287 | bar := NewProgressBar(1000000) |
| 288 | |
| 289 | // Update with very small increments |
| 290 | for i := range int64(11) { |
| 291 | output := bar.Update(i) |
| 292 | assert.NotEmpty(t, output, "Should handle very small increments") |
| 293 | } |
| 294 | }) |
| 295 | } |
| 296 | |
| 297 | func TestProgressBarConcurrency(t *testing.T) { |
| 298 | t.Run("multiple updates are safe", func(t *testing.T) { |
nothing calls this directly
no test coverage detected