mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
* [FEATURE] Allow for non-interactive age setup Also updates Go to Go 1.23.2 and get rid of min and max functions Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com> * [n/a] also renaming clear for Windows Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com> * [n/a] bumping our GHA to Go 1.23 Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com> * [n/a] make our harden runner softer Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com> * [n/a] make our harden runner accept go.dev Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com> * [n/a] applying code review changes Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com> --------- Signed-off-by: Yolan Romailler <AnomalRoil@users.noreply.github.com>
55 lines
840 B
Go
55 lines
840 B
Go
package termio
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func ExampleProgressBar() { //nolint:testableexamples
|
|
maxVal := 100
|
|
pb := NewProgressBar(int64(maxVal))
|
|
|
|
for range maxVal + 20 {
|
|
pb.Inc()
|
|
pb.Add(23)
|
|
pb.Set(42)
|
|
time.Sleep(150 * time.Millisecond)
|
|
}
|
|
|
|
time.Sleep(5 * time.Second)
|
|
pb.Done()
|
|
}
|
|
|
|
func TestProgress(t *testing.T) {
|
|
maxVal := 2
|
|
pb := NewProgressBar(int64(maxVal))
|
|
pb.Hidden = true
|
|
pb.Inc()
|
|
assert.Equal(t, int64(1), pb.current)
|
|
}
|
|
|
|
func TestProgressNil(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
var pb *ProgressBar
|
|
pb.Inc()
|
|
pb.Add(4)
|
|
pb.Done()
|
|
}
|
|
|
|
func TestProgressBytes(t *testing.T) {
|
|
maxSize := 2 << 24
|
|
pb := NewProgressBar(int64(maxSize))
|
|
pb.Hidden = true
|
|
pb.Bytes = true
|
|
|
|
for i := range 24 {
|
|
pb.Set(2 << (i + 1))
|
|
}
|
|
|
|
assert.Equal(t, int64(maxSize), pb.current)
|
|
pb.Done()
|
|
}
|