From 4e5b48c59033d6d5a0cc42433655eff485821794 Mon Sep 17 00:00:00 2001 From: Denis Romanov Date: Sun, 6 Nov 2022 00:43:34 +0300 Subject: [PATCH 1/2] Fix some style in tests --- progressbar_test.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/progressbar_test.go b/progressbar_test.go index ac4dc23..dcf2009 100644 --- a/progressbar_test.go +++ b/progressbar_test.go @@ -9,7 +9,6 @@ import ( "io/ioutil" "net/http" "os" - "strconv" "strings" "sync" "testing" @@ -122,7 +121,7 @@ func ExampleOptionShowIts() { // 10% |█ | (10 it/s) } -func ExampleOptionShowCountBigNumber() { +func ExampleOptionShowCount_minuscule() { bar := NewOptions(10000, OptionSetWidth(10), OptionShowCount(), OptionSetPredictTime(false)) bar.Add(1) // Output: @@ -143,7 +142,7 @@ func ExampleOptionShowDescriptionAtLineEnd() { // 10% |█ | [0s:0s] hello } -func ExampleOptionShowDescriptionAtLineEnd_WithSpinner() { +func ExampleOptionShowDescriptionAtLineEnd_spinner() { bar := NewOptions(-1, OptionSetWidth(10), OptionShowDescriptionAtLineEnd(), OptionSetDescription("hello")) _ = bar.Add(1) // Output: @@ -160,7 +159,7 @@ func ExampleDefault() { // } -func ExampleOptionChangeMax() { +func ExampleProgressBar_ChangeMax() { bar := NewOptions(100, OptionSetWidth(10), OptionSetPredictTime(false)) bar.ChangeMax(50) bar.Add(50) @@ -168,9 +167,9 @@ func ExampleOptionChangeMax() { // 100% |██████████| } -func ExampleIgnoreLength_WithIteration() { +func ExampleOptionShowIts_spinner() { /* - IgnoreLength test with iteration count and iteration rate + Spinner test with iteration count and iteration rate */ bar := NewOptions(-1, OptionSetWidth(10), @@ -230,9 +229,9 @@ func Test_IsFinished(t *testing.T) { } } -func ExampleIgnoreLength_WithSpeed() { +func ExampleOptionShowBytes_spinner() { /* - IgnoreLength test with iterations and count + Spinner test with iterations and count */ bar := NewOptions(-1, OptionSetWidth(10), @@ -400,7 +399,7 @@ func TestOptionSetPredictTime(t *testing.T) { func TestOptionSetElapsedTime(t *testing.T) { /* - IgnoreLength test with iteration count and iteration rate + Spinner test with iteration count and iteration rate */ bar := NewOptions(-1, OptionSetWidth(10), @@ -436,7 +435,7 @@ func TestShowElapsedTimeOnFinish(t *testing.T) { } } -func TestIgnoreLength(t *testing.T) { +func TestSpinnerState(t *testing.T) { bar := NewOptions( -1, OptionSetWidth(100), @@ -639,9 +638,13 @@ func TestProgressBar_Describe(t *testing.T) { bar := NewOptions(100, OptionSetWidth(10), OptionSetWriter(&buf)) bar.Describe("performing axial adjustments") bar.Add(10) - rawBuf := strconv.QuoteToASCII(buf.String()) - if rawBuf != `"\rperforming axial adjustments 0% | | [0s:0s]\r \r\rperforming axial adjustments 10% |\u2588 | [0s:0s]"` { - t.Errorf("wrong string: %s", rawBuf) + result := buf.String() + expect := "" + + "\rperforming axial adjustments 0% | | [0s:0s]" + + "\r \r" + + "\rperforming axial adjustments 10% |█ | [0s:0s]" + if result != expect { + t.Errorf("Render miss-match\nResult: '%s'\nExpect: '%s'\n%+v", result, expect, bar) } } From c6941e623dd5d9f41947225215e4e086c392fdd3 Mon Sep 17 00:00:00 2001 From: Denis Romanov Date: Sun, 6 Nov 2022 00:43:44 +0300 Subject: [PATCH 2/2] Add go vet to CI workflow --- .github/workflows/ci.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9abad0..dbe85cb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,5 @@ name: CI + on: push: branches: [main] @@ -6,13 +7,20 @@ on: branches: [main] jobs: - unit-tests: - name: Go unit tests + audit: + name: Audit runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 + - name: Set up Go + uses: actions/setup-go@v3 with: go-version: '1.18' - - run: go version - - run: go test -v -cover . + + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Run go vet + run: go vet . + + - name: Run go test + run: go test -v -cover -vet=off .