statview/stat_test.go

29 lines
393 B
Go

package statview
import (
"fmt"
"testing"
"time"
)
func TestStat(t *testing.T) {
view := New[int]()
fmt.Println("asd")
for i := 0; i < 5; i++ {
view.Add(i)
go func(id int) {
defer view.Done(id)
for p := 0; p <= 100; p++ {
view.Report(id, fmt.Sprintf("task %d: %3d%%", id, p))
time.Sleep(time.Duration(id+1) * 10 * time.Millisecond)
}
}(i)
}
view.Show()
}