Skip to content

Commit 9723d4e

Browse files
committed
Use type safe assertion package
1 parent 8ada716 commit 9723d4e

File tree

7 files changed

+23
-18
lines changed

7 files changed

+23
-18
lines changed

completion/completion_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package completion
33
import (
44
"testing"
55

6-
"github.com/stretchr/testify/assert"
6+
"github.com/alecthomas/assert/v2"
77
)
88

99
func generator(match string) []string {
@@ -40,7 +40,7 @@ func TestTabCompleter_Next(t *testing.T) {
4040
cmpl.Reset()
4141

4242
next = cmpl.Next("")
43-
assert.Empty(t, next)
43+
assert.Equal(t, "", next)
4444

4545
num = "none"
4646
next = cmpl.Next("none")
@@ -77,7 +77,7 @@ func TestTabCompleter_Previous(t *testing.T) {
7777
cmpl.Reset()
7878

7979
prev = cmpl.Previous("")
80-
assert.Empty(t, prev)
80+
assert.Equal(t, "", prev)
8181

8282
num = "none"
8383
prev = cmpl.Previous("none")

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ go 1.21
44

55
require (
66
fyne.io/fyne/v2 v2.5.3
7+
github.com/alecthomas/assert/v2 v2.11.0
78
github.com/fynelabs/fyneselfupdate v0.1.1
89
github.com/fynelabs/selfupdate v0.2.0
910
github.com/klauspost/compress v1.17.11
1011
github.com/rymdport/go-qrcode v1.2.0
1112
github.com/rymdport/wormhole v0.1.1-0.20241116103349-4e36e05aff6c
12-
github.com/stretchr/testify v1.9.0
1313
)
1414

1515
require (
1616
fyne.io/systray v1.11.0 // indirect
1717
github.com/BurntSushi/toml v1.4.0 // indirect
18+
github.com/alecthomas/repr v0.4.0 // indirect
1819
github.com/coder/websocket v1.8.12 // indirect
1920
github.com/davecgh/go-spew v1.1.1 // indirect
2021
github.com/fredbi/uri v1.1.0 // indirect
@@ -28,13 +29,15 @@ require (
2829
github.com/go-text/typesetting v0.2.0 // indirect
2930
github.com/godbus/dbus/v5 v5.1.0 // indirect
3031
github.com/gopherjs/gopherjs v1.17.2 // indirect
32+
github.com/hexops/gotextdiff v1.0.3 // indirect
3133
github.com/jeandeaual/go-locale v0.0.0-20240223122105-ce5225dcaa49 // indirect
3234
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
3335
github.com/nicksnyder/go-i18n/v2 v2.4.0 // indirect
3436
github.com/pmezard/go-difflib v1.0.0 // indirect
3537
github.com/rymdport/portal v0.3.0 // indirect
3638
github.com/srwiley/oksvg v0.0.0-20221011165216-be6e8873101c // indirect
3739
github.com/srwiley/rasterx v0.0.0-20220730225603-2ab79fcdd4ef // indirect
40+
github.com/stretchr/testify v1.9.0 // indirect
3841
github.com/yuin/goldmark v1.7.1 // indirect
3942
golang.org/x/crypto v0.31.0 // indirect
4043
golang.org/x/image v0.18.0 // indirect

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
4545
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
4646
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
4747
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
48+
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
49+
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
50+
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
51+
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
4852
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
4953
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
5054
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY=
@@ -202,6 +206,8 @@ github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO
202206
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
203207
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
204208
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
209+
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
210+
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
205211
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
206212
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
207213
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=

internal/transport/completion_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package transport
33
import (
44
"testing"
55

6-
"github.com/stretchr/testify/assert"
6+
"github.com/alecthomas/assert/v2"
77
)
88

99
var completions []string

internal/util/reader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"bytes"
55
"testing"
66

7-
"github.com/stretchr/testify/assert"
7+
"github.com/alecthomas/assert/v2"
88
)
99

1010
func TestProgressReader(t *testing.T) {

internal/util/url_test.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ package util
22

33
import (
44
"net/url"
5-
"reflect"
65
"testing"
6+
7+
"github.com/alecthomas/assert/v2"
78
)
89

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

30-
if got := URLToGitHubProject(tt.subpath); !reflect.DeepEqual(got, want) {
31-
t.Errorf("URLToGitHubProject() = %v, want %v", got, want)
32-
}
28+
got := URLToGitHubProject(tt.subpath)
29+
assert.Equal(t, want, got)
3330
})
3431
}
3532
}

internal/util/util_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import (
55
"testing"
66

77
"fyne.io/fyne/v2"
8-
"github.com/stretchr/testify/assert"
8+
9+
"github.com/alecthomas/assert/v2"
910
)
1011

1112
var globalValidationError error
@@ -46,9 +47,7 @@ var codeValidatorTestcases = []struct {
4647
func TestCodeValidator(t *testing.T) {
4748
for _, tc := range codeValidatorTestcases {
4849
out := CodeValidator(tc.in)
49-
if out != tc.want {
50-
t.Errorf("CodeValidator with input \"%s\" returned: %v, want \"%v\"", tc.in, out, tc.want)
51-
}
50+
assert.Equal(t, tc.want, out)
5251
}
5352
}
5453

0 commit comments

Comments
 (0)