[PR #15377] progress: add unit tests for bar, spinner, and stepbar #25671

Open
opened 2026-04-19 18:20:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15377
Author: @saaman-mahmoodi
Created: 4/7/2026
Status: 🔄 Open

Base: mainHead: add-tests-progress


📝 Commits (2)

  • 27c0752 auth, logutil: add unit tests
  • ddaf272 progress: add unit tests for bar, spinner, and stepbar

📊 Changes

5 files changed (+1047 additions, -0 deletions)

View changed files

auth/auth_test.go (+289 -0)
logutil/logutil_test.go (+217 -0)
progress/bar_test.go (+236 -0)
progress/spinner_test.go (+152 -0)
progress/stepbar_test.go (+153 -0)

📄 Description

Summary

Adds comprehensive unit test coverage for the progress package, which provides terminal progress bar UI components:

  • Bar: Progress bar with percentage, rate calculation, and time remaining
  • Spinner: Animated spinner with message updates
  • StepBar: Step-based progress indicator

Test Coverage Added

progress/bar_test.go

  • TestFormatDuration: Duration formatting for various ranges (zero, seconds, minutes, hours, 100h+)
  • TestNewBar: Bar creation with various initial/max values
  • TestBar_percent: Percentage calculation edge cases
  • TestBar_Set: Value updates, capping at max, stopped state
  • TestBar_rate: Rate calculation from buckets
  • TestBar_String: Output format verification
  • TestRepeat: String repetition helper

progress/spinner_test.go

  • TestNewSpinner: Spinner creation and initialization
  • TestSpinner_SetMessage: Atomic message updates (including concurrent)
  • TestSpinner_String: Output format, animation display, stopped state
  • TestSpinner_Stop: Stop behavior and idempotency

progress/stepbar_test.go

  • TestNewStepBar: Creation with message and total
  • TestStepBar_Set: Current step updates
  • TestStepBar_String: Output format, percentages, edge cases

Testing

All tests pass:

go test ./progress/... -v
ok  	github.com/ollama/ollama/progress	0.643s

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15377 **Author:** [@saaman-mahmoodi](https://github.com/saaman-mahmoodi) **Created:** 4/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `add-tests-progress` --- ### 📝 Commits (2) - [`27c0752`](https://github.com/ollama/ollama/commit/27c0752d7d52e878a8b62d786002d42541e1c982) auth, logutil: add unit tests - [`ddaf272`](https://github.com/ollama/ollama/commit/ddaf27230faaf2c69746c7a0d3831502c877c620) progress: add unit tests for bar, spinner, and stepbar ### 📊 Changes **5 files changed** (+1047 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `auth/auth_test.go` (+289 -0) ➕ `logutil/logutil_test.go` (+217 -0) ➕ `progress/bar_test.go` (+236 -0) ➕ `progress/spinner_test.go` (+152 -0) ➕ `progress/stepbar_test.go` (+153 -0) </details> ### 📄 Description ## Summary Adds comprehensive unit test coverage for the progress package, which provides terminal progress bar UI components: - **Bar**: Progress bar with percentage, rate calculation, and time remaining - **Spinner**: Animated spinner with message updates - **StepBar**: Step-based progress indicator ## Test Coverage Added ### `progress/bar_test.go` - `TestFormatDuration`: Duration formatting for various ranges (zero, seconds, minutes, hours, 100h+) - `TestNewBar`: Bar creation with various initial/max values - `TestBar_percent`: Percentage calculation edge cases - `TestBar_Set`: Value updates, capping at max, stopped state - `TestBar_rate`: Rate calculation from buckets - `TestBar_String`: Output format verification - `TestRepeat`: String repetition helper ### `progress/spinner_test.go` - `TestNewSpinner`: Spinner creation and initialization - `TestSpinner_SetMessage`: Atomic message updates (including concurrent) - `TestSpinner_String`: Output format, animation display, stopped state - `TestSpinner_Stop`: Stop behavior and idempotency ### `progress/stepbar_test.go` - `TestNewStepBar`: Creation with message and total - `TestStepBar_Set`: Current step updates - `TestStepBar_String`: Output format, percentages, edge cases ## Testing All tests pass: ``` go test ./progress/... -v ok github.com/ollama/ollama/progress 0.643s ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 18:20:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#25671