Skip to content

Commit

Permalink
Use type safe assertion package
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacalz committed Jan 21, 2025
1 parent 8ada716 commit 9723d4e
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
6 changes: 3 additions & 3 deletions completion/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package completion
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/alecthomas/assert/v2"
)

func generator(match string) []string {
Expand Down Expand Up @@ -40,7 +40,7 @@ func TestTabCompleter_Next(t *testing.T) {
cmpl.Reset()

next = cmpl.Next("")
assert.Empty(t, next)
assert.Equal(t, "", next)

num = "none"
next = cmpl.Next("none")
Expand Down Expand Up @@ -77,7 +77,7 @@ func TestTabCompleter_Previous(t *testing.T) {
cmpl.Reset()

prev = cmpl.Previous("")
assert.Empty(t, prev)
assert.Equal(t, "", prev)

num = "none"
prev = cmpl.Previous("none")
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ go 1.21

require (
fyne.io/fyne/v2 v2.5.3
github.com/alecthomas/assert/v2 v2.11.0
github.com/fynelabs/fyneselfupdate v0.1.1
github.com/fynelabs/selfupdate v0.2.0
github.com/klauspost/compress v1.17.11
github.com/rymdport/go-qrcode v1.2.0
github.com/rymdport/wormhole v0.1.1-0.20241116103349-4e36e05aff6c
github.com/stretchr/testify v1.9.0
)

require (
fyne.io/systray v1.11.0 // indirect
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/alecthomas/repr v0.4.0 // indirect
github.com/coder/websocket v1.8.12 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fredbi/uri v1.1.0 // indirect
Expand All @@ -28,13 +29,15 @@ require (
github.com/go-text/typesetting v0.2.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/jeandeaual/go-locale v0.0.0-20240223122105-ce5225dcaa49 // indirect
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
github.com/nicksnyder/go-i18n/v2 v2.4.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rymdport/portal v0.3.0 // indirect
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
github.com/stretchr/testify v1.9.0 // indirect
github.com/yuin/goldmark v1.7.1 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/image v0.18.0 // indirect
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
Expand Down Expand Up @@ -202,6 +206,8 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
Expand Down
2 changes: 1 addition & 1 deletion internal/transport/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package transport
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/alecthomas/assert/v2"
)

var completions []string
Expand Down
2 changes: 1 addition & 1 deletion internal/util/reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"testing"

"github.com/stretchr/testify/assert"
"github.com/alecthomas/assert/v2"
)

func TestProgressReader(t *testing.T) {
Expand Down
13 changes: 5 additions & 8 deletions internal/util/url_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package util

import (
"net/url"
"reflect"
"testing"

"github.com/alecthomas/assert/v2"
)

func TestURLToGitHubProject(t *testing.T) {
Expand All @@ -22,14 +23,10 @@ func TestURLToGitHubProject(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
path := basepath + tt.subpath
want, err := url.Parse(path)
if err != nil {
t.Errorf("Failed to parse the path %s: %v", path, err)
return
}
assert.NoError(t, err)

if got := URLToGitHubProject(tt.subpath); !reflect.DeepEqual(got, want) {
t.Errorf("URLToGitHubProject() = %v, want %v", got, want)
}
got := URLToGitHubProject(tt.subpath)
assert.Equal(t, want, got)
})
}
}
7 changes: 3 additions & 4 deletions internal/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (
"testing"

"fyne.io/fyne/v2"
"github.com/stretchr/testify/assert"

"github.com/alecthomas/assert/v2"
)

var globalValidationError error
Expand Down Expand Up @@ -46,9 +47,7 @@ var codeValidatorTestcases = []struct {
func TestCodeValidator(t *testing.T) {
for _, tc := range codeValidatorTestcases {
out := CodeValidator(tc.in)
if out != tc.want {
t.Errorf("CodeValidator with input \"%s\" returned: %v, want \"%v\"", tc.in, out, tc.want)
}
assert.Equal(t, tc.want, out)
}
}

Expand Down

0 comments on commit 9723d4e

Please sign in to comment.