Skip to content

Commit

Permalink
refactor: replace testify with testza
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvinJWendt committed Jul 19, 2021
1 parent ed012cd commit b052075
Show file tree
Hide file tree
Showing 31 changed files with 388 additions and 397 deletions.
5 changes: 2 additions & 3 deletions area_printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/MarvinJWendt/testza"
"github.com/pterm/pterm"
"github.com/stretchr/testify/assert"
)

func TestAreaPrinter_NilPrint(t *testing.T) {
Expand Down Expand Up @@ -59,12 +58,12 @@ func TestAreaPrinter_WithRemoveWhenDone(t *testing.T) {
p := pterm.AreaPrinter{}
p2 := p.WithRemoveWhenDone()

assert.True(t, p2.RemoveWhenDone)
testza.AssertTrue(t, p2.RemoveWhenDone)
}

func TestAreaPrinter_WithFullscreen(t *testing.T) {
p := pterm.AreaPrinter{}
p2 := p.WithFullscreen()

assert.True(t, p2.Fullscreen)
testza.AssertTrue(t, p2.Fullscreen)
}
18 changes: 9 additions & 9 deletions atoms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,42 @@ package pterm_test
import (
"testing"

"github.com/MarvinJWendt/testza"
"github.com/pterm/pterm"
"github.com/stretchr/testify/assert"
)

func TestBar_WithLabel(t *testing.T) {
p := pterm.Bar{}
s := "X"
p2 := p.WithLabel(s)

assert.Equal(t, s, p2.Label)
assert.Empty(t, p.Label)
testza.AssertEqual(t, s, p2.Label)
testza.AssertZero(t, p.Label)
}

func TestBar_WithStyle(t *testing.T) {
p := pterm.Bar{}
s := pterm.NewStyle(pterm.FgRed, pterm.BgBlue, pterm.Bold)
p2 := p.WithStyle(s)

assert.Equal(t, s, p2.Style)
assert.Empty(t, p.Style)
testza.AssertEqual(t, s, p2.Style)
testza.AssertZero(t, p.Style)
}

func TestBar_WithValue(t *testing.T) {
p := pterm.Bar{}
s := 1337
p2 := p.WithValue(s)

assert.Equal(t, s, p2.Value)
assert.Empty(t, p.Value)
testza.AssertEqual(t, s, p2.Value)
testza.AssertZero(t, p.Value)
}

func TestBar_WithLabelStyle(t *testing.T) {
p := pterm.Bar{}
s := pterm.NewStyle(pterm.FgRed, pterm.BgBlue, pterm.Bold)
p2 := p.WithLabelStyle(s)

assert.Equal(t, s, p2.LabelStyle)
assert.Empty(t, p.LabelStyle)
testza.AssertEqual(t, s, p2.LabelStyle)
testza.AssertZero(t, p.LabelStyle)
}
30 changes: 15 additions & 15 deletions barchart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package pterm_test
import (
"testing"

"github.com/MarvinJWendt/testza"
"github.com/pterm/pterm"
"github.com/stretchr/testify/assert"
)

func TestBarChartPrinterNilPrint(t *testing.T) {
Expand Down Expand Up @@ -202,17 +202,17 @@ func TestBarChartPrinter_WithHorizontalBarCharacter(t *testing.T) {
s := "X"
p2 := p.WithHorizontalBarCharacter(s)

assert.Equal(t, s, p2.HorizontalBarCharacter)
assert.Empty(t, p.HorizontalBarCharacter)
testza.AssertEqual(t, s, p2.HorizontalBarCharacter)
testza.AssertZero(t, p.HorizontalBarCharacter)
}

func TestBarChartPrinter_WithVerticalBarCharacter(t *testing.T) {
p := pterm.BarChartPrinter{}
s := "X"
p2 := p.WithVerticalBarCharacter(s)

assert.Equal(t, s, p2.VerticalBarCharacter)
assert.Empty(t, p.VerticalBarCharacter)
testza.AssertEqual(t, s, p2.VerticalBarCharacter)
testza.AssertZero(t, p.VerticalBarCharacter)
}

func TestBarChartPrinter_WithBars(t *testing.T) {
Expand All @@ -231,42 +231,42 @@ func TestBarChartPrinter_WithBars(t *testing.T) {
}
p2 := p.WithBars(s)

assert.Equal(t, s, p2.Bars)
assert.Empty(t, p.Bars)
testza.AssertEqual(t, s, p2.Bars)
testza.AssertZero(t, p.Bars)
}

func TestBarChartPrinter_WithHeight(t *testing.T) {
p := pterm.BarChartPrinter{}
s := 1337
p2 := p.WithHeight(s)

assert.Equal(t, s, p2.Height)
assert.Empty(t, p.Height)
testza.AssertEqual(t, s, p2.Height)
testza.AssertZero(t, p.Height)
}

func TestBarChartPrinter_WithHorizontal(t *testing.T) {
p := pterm.BarChartPrinter{}
s := true
p2 := p.WithHorizontal(s)

assert.Equal(t, s, p2.Horizontal)
assert.Empty(t, p.Horizontal)
testza.AssertEqual(t, s, p2.Horizontal)
testza.AssertZero(t, p.Horizontal)
}

func TestBarChartPrinter_WithShowValue(t *testing.T) {
p := pterm.BarChartPrinter{}
s := true
p2 := p.WithShowValue(s)

assert.Equal(t, s, p2.ShowValue)
assert.Empty(t, p.ShowValue)
testza.AssertEqual(t, s, p2.ShowValue)
testza.AssertZero(t, p.ShowValue)
}

func TestBarChartPrinter_WithWidth(t *testing.T) {
p := pterm.BarChartPrinter{}
s := 1337
p2 := p.WithWidth(s)

assert.Equal(t, s, p2.Width)
assert.Empty(t, p.Width)
testza.AssertEqual(t, s, p2.Width)
testza.AssertZero(t, p.Width)
}
8 changes: 4 additions & 4 deletions basic_text_printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"io"
"testing"

"github.com/MarvinJWendt/testza"
"github.com/pterm/pterm"
"github.com/stretchr/testify/assert"
)

func TestBasicTextPrinterNilPrint(t *testing.T) {
Expand Down Expand Up @@ -70,14 +70,14 @@ func TestBasicTextPrinterPrintMethods(t *testing.T) {
result := captureStdout(func(w io.Writer) {
p.PrintOnError(errors.New("hello world"))
})
assert.Contains(t, result, "hello world")
testza.AssertContains(t, result, "hello world")
})

t.Run("PrintIfError_WithoutError", func(t *testing.T) {
result := captureStdout(func(w io.Writer) {
p.PrintOnError(nil)
})
assert.Empty(t, result)
testza.AssertZero(t, result)
})
}

Expand All @@ -86,5 +86,5 @@ func TestBasicTextPrinter_WithStyle(t *testing.T) {
p := pterm.BasicTextPrinter{}
p2 := p.WithStyle(s)

assert.Equal(t, s, p2.Style)
testza.AssertEqual(t, s, p2.Style)
}
24 changes: 12 additions & 12 deletions bigtext_printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strings"
"testing"

"github.com/MarvinJWendt/testza"
"github.com/pterm/pterm"
"github.com/stretchr/testify/assert"
)

func TestBigTextPrinterNilPrint(t *testing.T) {
Expand All @@ -33,8 +33,8 @@ func TestBigTextPrinter_WithBigCharacters(t *testing.T) {
p := pterm.BigTextPrinter{}
p2 := p.WithBigCharacters(e)

assert.Equal(t, e, p2.BigCharacters)
assert.Empty(t, p.BigCharacters)
testza.AssertEqual(t, e, p2.BigCharacters)
testza.AssertZero(t, p.BigCharacters)
}

func TestBigTextPrinter_WithLetters(t *testing.T) {
Expand All @@ -51,26 +51,26 @@ func TestBigTextPrinter_WithLetters(t *testing.T) {
p := pterm.BigTextPrinter{}
p2 := p.WithLetters(e)

assert.Equal(t, e, p2.Letters)
assert.Empty(t, p.Letters)
testza.AssertEqual(t, e, p2.Letters)
testza.AssertZero(t, p.Letters)
}

func TestLetter_WithString(t *testing.T) {
e := "Hello, World!"
p := pterm.Letter{}
p2 := p.WithString(e)

assert.Equal(t, e, p2.String)
assert.Empty(t, p.String)
testza.AssertEqual(t, e, p2.String)
testza.AssertZero(t, p.String)
}

func TestLetter_WithStyle(t *testing.T) {
p := pterm.Letter{}
s := pterm.NewStyle(pterm.FgRed, pterm.BgRed, pterm.Bold)
p2 := p.WithStyle(s)

assert.Equal(t, s, p2.Style)
assert.Empty(t, p.Style)
testza.AssertEqual(t, s, p2.Style)
testza.AssertZero(t, p.Style)
}

func TestNewLettersFromText(t *testing.T) {
Expand All @@ -86,7 +86,7 @@ func TestNewLettersFromText(t *testing.T) {
}
p := pterm.NewLettersFromString("ab")

assert.Equal(t, e, p)
testza.AssertEqual(t, e, p)
}

func TestNewLettersFromTextWithStyle(t *testing.T) {
Expand All @@ -102,14 +102,14 @@ func TestNewLettersFromTextWithStyle(t *testing.T) {
}
p := pterm.NewLettersFromStringWithStyle("ab", pterm.NewStyle(pterm.FgRed, pterm.BgBlue, pterm.Bold))

assert.Equal(t, e, p)
testza.AssertEqual(t, e, p)
}

func TestDefaultLettersMaxHeight(t *testing.T) {
maxHeight := 5
chars := pterm.DefaultBigText.BigCharacters
for s, l := range chars {
h := strings.Count(l, "\n")
assert.LessOrEqualf(t, h, maxHeight, "'%s' is too high", s)
testza.AssertTrue(t, h <= maxHeight, "'%s' is too high", s)
}
}
Loading

0 comments on commit b052075

Please sign in to comment.