Skip to content

Commit

Permalink
Merge pull request #144 from oerlikon/fix-vet-tests
Browse files Browse the repository at this point in the history
Make go vet happy
  • Loading branch information
schollz committed Nov 6, 2022
2 parents 56c5e5b + c6941e6 commit 84d4294
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
@@ -1,18 +1,26 @@
name: CI

on:
push:
branches: [main]
pull_request:
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 .
29 changes: 16 additions & 13 deletions progressbar_test.go
Expand Up @@ -8,7 +8,6 @@ import (
"io"
"net/http"
"os"
"strconv"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -121,7 +120,7 @@ func ExampleOptionShowIts() {
// 10% |█ | (10 it/s)
}

func ExampleOptionShowCountBigNumber() {
func ExampleOptionShowCount_minuscule() {
bar := NewOptions(10000, OptionSetWidth(10), OptionShowCount(), OptionSetPredictTime(false))
bar.Add(1)
// Output:
Expand All @@ -142,7 +141,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:
Expand All @@ -159,17 +158,17 @@ func ExampleDefault() {
//
}

func ExampleOptionChangeMax() {
func ExampleProgressBar_ChangeMax() {
bar := NewOptions(100, OptionSetWidth(10), OptionSetPredictTime(false))
bar.ChangeMax(50)
bar.Add(50)
// Output:
// 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),
Expand Down Expand Up @@ -229,9 +228,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),
Expand Down Expand Up @@ -399,7 +398,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),
Expand Down Expand Up @@ -435,7 +434,7 @@ func TestShowElapsedTimeOnFinish(t *testing.T) {
}
}

func TestIgnoreLength(t *testing.T) {
func TestSpinnerState(t *testing.T) {
bar := NewOptions(
-1,
OptionSetWidth(100),
Expand Down Expand Up @@ -638,9 +637,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)
}
}

Expand Down

0 comments on commit 84d4294

Please sign in to comment.