Skip to content

Commit 5c929d2

Browse files
authored
Merge pull request #1340 from afbjorklund/test-progress
Hide download progress when running tests
2 parents d8e5fe8 + 517bb53 commit 5c929d2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/downloader/downloader.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"github.com/sirupsen/logrus"
2020
)
2121

22+
var HideProgress bool
23+
2224
type Status = string
2325

2426
const (
@@ -297,6 +299,9 @@ func createBar(size int64) (*pb.ProgressBar, error) {
297299
if isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd()) {
298300
bar.SetTemplateString(`{{counters . }} {{bar . | green }} {{percent .}} {{speed . "%s/s"}}`)
299301
bar.SetRefreshRate(200 * time.Millisecond)
302+
} else if HideProgress {
303+
bar.Set(pb.ReturnSymbol, "")
304+
bar.SetTemplateString("")
300305
} else {
301306
bar.Set(pb.Terminal, false)
302307
bar.Set(pb.ReturnSymbol, "\n")

pkg/downloader/downloader_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ const (
1717
dummyRemoteFileDigest = "sha256:58d2de96f9d91f0acd93cb1e28bf7c42fc86079037768d6aa63b4e7e7b3c9be0"
1818
)
1919

20+
func TestMain(m *testing.M) {
21+
HideProgress = true
22+
os.Exit(m.Run())
23+
}
24+
2025
func TestDownloadRemote(t *testing.T) {
2126
if testing.Short() {
2227
t.Skip()

0 commit comments

Comments
 (0)