From a9a384972649182c188396c5f996ae617d35188a Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Mon, 24 Aug 2026 12:07:30 +0200 Subject: Add progress bars to the long-running CLI processes (backtest, backfill, extract-osm) --- mountain_pass/extract_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'mountain_pass/extract_test.go') diff --git a/mountain_pass/extract_test.go b/mountain_pass/extract_test.go index 636372c..7eae33b 100644 --- a/mountain_pass/extract_test.go +++ b/mountain_pass/extract_test.go @@ -1,10 +1,13 @@ package mountain_pass import ( + "io" + "strings" "testing" "github.com/paulmach/osm" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestIsMountainPass(t *testing.T) { @@ -47,3 +50,21 @@ func TestParseElevation(t *testing.T) { assert.Equal(t, c.ok, ok) } } + +func TestCountingReaderTracksBytes(t *testing.T) { + const content = "0123456789abcdef" + reader := &countingReader{r: strings.NewReader(content)} + + buf := make([]byte, 4) + var total int64 + for { + n, err := reader.Read(buf) + total += int64(n) + require.Equal(t, total, reader.n) + if err == io.EOF { + break + } + require.NoError(t, err) + } + assert.Equal(t, int64(len(content)), reader.n) +} -- cgit v1.3