File: progress_bars_test.go

package info (click to toggle)
golang-github-containers-image 5.36.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 5,152 kB
  • sloc: sh: 267; makefile: 100
file content (24 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package copy

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/vbauerster/mpb/v8/decor"
)

func TestCustomPartialBlobDecorFunc(t *testing.T) {
	// A stub test
	s := decor.Statistics{}
	assert.Equal(t, "0.0b / 0.0b (skipped: 0.0b)", customPartialBlobDecorFunc(s))
	// Partial pull in progress
	s = decor.Statistics{}
	s.Current = 1097653
	s.Total = 8329917
	s.Refill = 509722
	assert.Equal(t, "1.0MiB / 7.9MiB (skipped: 497.8KiB = 6.12%)", customPartialBlobDecorFunc(s))
	// Almost complete, but no reuse
	s.Current = int64(float64(s.Total) * 0.95)
	s.Refill = 0
	assert.Equal(t, "7.5MiB / 7.9MiB", customPartialBlobDecorFunc(s))
}