diff options
| author | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-24 12:07:30 +0200 |
|---|---|---|
| committer | Martin Kagamino Lehoux <martin@lehoux.net> | 2026-08-24 12:07:30 +0200 |
| commit | a9a384972649182c188396c5f996ae617d35188a (patch) | |
| tree | dc5d317d33643629acb605137626eba920b0ba18 /mountain_pass/extract_test.go | |
| parent | 3646cc0d06d077a4881b611ac845c3a6ee6dd54d (diff) | |
Add progress bars to the long-running CLI processes (backtest, backfill, extract-osm)
Diffstat (limited to 'mountain_pass/extract_test.go')
| -rw-r--r-- | mountain_pass/extract_test.go | 21 |
1 files changed, 21 insertions, 0 deletions
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) +} |
