1
1
mirror of https://github.com/walles/moar.git synced 2024-09-11 12:15:43 +03:00

Simplify test expectations

This commit is contained in:
Johan Walles 2022-09-22 20:53:59 +02:00
parent 8d9c2be69f
commit 38ed948da3
3 changed files with 15 additions and 18 deletions

1
go.mod
View File

@ -7,6 +7,7 @@ require (
github.com/google/go-cmp v0.5.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.8.0 // indirect
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744
golang.org/x/term v0.0.0-20210503060354-a79de5458b56
gotest.tools v2.2.0+incompatible

7
go.sum
View File

@ -14,9 +14,14 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744 h1:yhBbb4IRs2HS9PPlAg6DMC6mUOKexJBNsLf4Z+6En1Q=
@ -28,5 +33,7 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=

View File

@ -4,6 +4,7 @@ import (
"strings"
"testing"
"github.com/stretchr/testify/require"
"github.com/walles/moar/twin"
)
@ -19,9 +20,7 @@ func createThreeLinesPager(t *testing.T) *Pager {
pager.screen = screen
if pager.mode != _Viewing {
t.Errorf("Expected initial pager state to be %v but got %v", _Viewing, pager.mode)
}
require.Equal(t, _Viewing, pager.mode, "Initial pager state")
return pager
}
@ -38,9 +37,7 @@ func TestScrollToNextSearchHit_StartAtBottom(t *testing.T) {
// Scroll to the next search hit
pager.scrollToNextSearchHit()
if pager.mode != _NotFound {
t.Errorf("Expected state %v but got %v", _NotFound, pager.mode)
}
require.Equal(t, _NotFound, pager.mode)
}
func TestScrollToNextSearchHit_StartAtTop(t *testing.T) {
@ -54,9 +51,7 @@ func TestScrollToNextSearchHit_StartAtTop(t *testing.T) {
// Scroll to the next search hit
pager.scrollToNextSearchHit()
if pager.mode != _NotFound {
t.Errorf("Expected state %v but got %v", _NotFound, pager.mode)
}
require.Equal(t, _NotFound, pager.mode)
}
func TestScrollToNextSearchHit_WrapAfterNotFound(t *testing.T) {
@ -70,17 +65,11 @@ func TestScrollToNextSearchHit_WrapAfterNotFound(t *testing.T) {
// Scroll to the next search hit, this should take us into _NotFound
pager.scrollToNextSearchHit()
if pager.mode != _NotFound {
t.Errorf("Expected state %v but got %v", _NotFound, pager.mode)
}
require.Equal(t, _NotFound, pager.mode)
// Scroll to the next search hit, this should wrap the search and take us to
// the top
pager.scrollToNextSearchHit()
if pager.mode != _Viewing {
t.Errorf("Expected state %v but got %v", _Viewing, pager.mode)
}
if pager.lineNumberOneBased() != 1 {
t.Errorf("Expected line number %v but got %v", 1, pager.lineNumberOneBased())
}
require.Equal(t, _Viewing, pager.mode)
require.Equal(t, 1, pager.lineNumberOneBased())
}