Add testify for simpler tests

This commit is contained in:
Dan Jones 2023-10-31 15:41:24 -05:00
commit 739bed214c
3 changed files with 11 additions and 8 deletions

4
go.mod
View file

@ -13,21 +13,25 @@ require (
github.com/rivo/tview v0.0.0-20230826224341-9754ab44dc1c
github.com/rkoesters/xdg v0.0.1
github.com/spf13/cobra v1.7.0
github.com/stretchr/testify v1.7.0
github.com/u2takey/ffmpeg-go v0.5.0
golang.org/x/term v0.11.0
)
require (
github.com/aws/aws-sdk-go v1.38.20 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/gdamore/encoding v1.0.0 // indirect
github.com/gdamore/tcell/v2 v2.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/u2takey/go-utils v0.3.1 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/text v0.7.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

1
go.sum
View file

@ -117,6 +117,7 @@ golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGm
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

View file

@ -2,13 +2,13 @@ package utils
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTern(t *testing.T) {
out := Tern(true, 5, 2)
if out != 5 {
t.Fatalf(`Tern(%v, %d, %d) = %v, want %d`, true, 5, 2, out, 5)
}
assert.Equal(t, Tern(true, 5, 2), 5)
assert.Equal(t, Tern(false, 5, 2), 2)
}
func TestTernCall(t *testing.T) {
@ -18,8 +18,6 @@ func TestTernCall(t *testing.T) {
two := func() int {
return 2
}
out := TernCall(true, five, two)
if out != 5 {
t.Fatalf(`TernCall(%v, func () { return 5}, func () {return 2}) = %v, want %d`, true, out, 5)
}
assert.Equal(t, TernCall(true, five, two), 5)
assert.Equal(t, TernCall(false, five, two), 2)
}