From 83deae2b4c56cd5e05e1c83b7977ced9e82a5300 Mon Sep 17 00:00:00 2001 From: Victor Elias Date: Wed, 19 Jun 2024 21:34:10 +0100 Subject: [PATCH] Fix tests --- catalyst-uploader.go | 9 +++++++++ core/uploader_test.go | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/catalyst-uploader.go b/catalyst-uploader.go index 14fe67f..d6cf3b0 100644 --- a/catalyst-uploader.go +++ b/catalyst-uploader.go @@ -29,11 +29,13 @@ func run() int { glog.Error(err) return 1 } + vFlag := flag.Lookup("v") fs := flag.NewFlagSet("catalyst-uploader", flag.ExitOnError) // cmd line args version := fs.Bool("version", false, "print application version") describe := fs.Bool("j", false, "Describe supported storage services in JSON format and exit") + verbosity := fs.String("v", "", "Log verbosity. {4|5|6}") timeout := fs.Duration("t", 30*time.Second, "Upload timeout") storageBackupURLs := jsonFlag[core.StorageBackupURLs](fs, "storage-backup-urls", `JSON array of {"primary":X,"backup":Y} objects with base storage URLs. If a file fails uploading to one of the primary storages (detected by prefix), it will fallback to the corresponding backup URL after having the prefix replaced`) @@ -69,6 +71,13 @@ func run() int { return 1 } + if *verbosity != "" { + err = vFlag.Value.Set(*verbosity) + if err != nil { + glog.Fatal(err) + } + } + // replace stdout to prevent any lib from writing debug output there stdout := os.Stdout os.Stdout, _ = os.Open(os.DevNull) diff --git a/core/uploader_test.go b/core/uploader_test.go index 120ce07..28a9054 100644 --- a/core/uploader_test.go +++ b/core/uploader_test.go @@ -35,7 +35,7 @@ func TestItWritesSlowInputIncrementally(t *testing.T) { go func() { u, err := url.Parse(outputFile.Name()) require.NoError(t, err) - _, err = Upload(slowReader, u, 100*time.Millisecond, time.Second) + _, err = Upload(slowReader, u, 100*time.Millisecond, time.Second, nil) require.NoError(t, err, "") }()