Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make go vet happy #144

Merged
merged 2 commits into from Nov 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -9,7 +9,6 @@ import (
"io/ioutil"
"net/http"
"os"
"strconv"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -160,17 +159,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 @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -436,7 +435,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 @@ -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)
}
}

Expand Down