MCPcopy Create free account
hub / github.com/github/gh-aw / TestProgressBarNonTTYFallback

Function TestProgressBarNonTTYFallback

pkg/console/progress_test.go:309–328  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

307}
308
309func TestProgressBarNonTTYFallback(t *testing.T) {
310 // This test documents the expected behavior in non-TTY environments
311 t.Run("non-TTY output is human readable", func(t *testing.T) {
312 // Skip if running in TTY mode as we can't test the fallback
313 if isTTY() {
314 t.Skip("Test requires non-TTY mode to validate fallback behavior")
315 }
316
317 bar := NewProgressBar(1024 * 1024) // 1MB total
318 output := bar.Update(512 * 1024) // 512KB downloaded
319
320 // Should produce something like: "50% (512.0KB/1.0MB)"
321 assert.Contains(t, output, "50%", "Should show percentage")
322 assert.Contains(t, output, "512.0KB", "Should show current size")
323 assert.Contains(t, output, "1.0MB", "Should show total size")
324 assert.Contains(t, output, "(", "Should have opening parenthesis")
325 assert.Contains(t, output, ")", "Should have closing parenthesis")
326 assert.Contains(t, output, "/", "Should have separator")
327 })
328}
329
330func TestProgressBarModeSelection(t *testing.T) {
331 t.Run("determinate mode has total and not indeterminate", func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

UpdateMethod · 0.95
isTTYFunction · 0.70
NewProgressBarFunction · 0.70
RunMethod · 0.45

Tested by

no test coverage detected