Skip to content

Commit 6d865b3

Browse files
committed
refactor: remove testify
1 parent 143f093 commit 6d865b3

File tree

3 files changed

+43
-21
lines changed

3 files changed

+43
-21
lines changed

go.mod

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ require (
2323
github.com/remeh/sizedwaitgroup v1.0.0
2424
github.com/smacker/go-tree-sitter v0.0.0-20240827094217-dd81d9e9be82
2525
github.com/spf13/pflag v1.0.5
26-
github.com/stretchr/testify v1.10.0
2726
github.com/tomwright/dasel/v2 v2.8.1
2827
github.com/yuin/goldmark v1.7.8
2928
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8
@@ -38,18 +37,17 @@ require (
3837
github.com/Masterminds/goutils v1.1.1 // indirect
3938
github.com/Masterminds/semver/v3 v3.3.1 // indirect
4039
github.com/atomicgo/cursor v0.0.1 // indirect
41-
github.com/davecgh/go-spew v1.1.1 // indirect
4240
github.com/google/uuid v1.6.0 // indirect
4341
github.com/gookit/color v1.5.4 // indirect
4442
github.com/huandu/xstrings v1.5.0 // indirect
4543
github.com/mattn/go-runewidth v0.0.16 // indirect
4644
github.com/mitchellh/copystructure v1.2.0 // indirect
4745
github.com/mitchellh/reflectwalk v1.0.2 // indirect
4846
github.com/montanaflynn/stats v0.7.1 // indirect
49-
github.com/pmezard/go-difflib v1.0.0 // indirect
5047
github.com/rivo/uniseg v0.4.7 // indirect
5148
github.com/shopspring/decimal v1.4.0 // indirect
5249
github.com/spf13/cast v1.7.1 // indirect
50+
github.com/stretchr/testify v1.10.0 // indirect
5351
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
5452
golang.org/x/crypto v0.32.0 // indirect
5553
golang.org/x/sync v0.10.0 // indirect

internal/core/ini_test.go

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package core
22

33
import (
4+
"strings"
45
"testing"
5-
6-
"github.com/stretchr/testify/assert"
76
)
87

98
func Test_processConfig_commentDelimiters(t *testing.T) {
@@ -18,7 +17,7 @@ func Test_processConfig_commentDelimiters(t *testing.T) {
1817
CommentDelimiters = "{/*,*/}"
1918
`,
2019
expected: map[string][2]string{
21-
"*.md": [2]string{"{/*", "*/}"},
20+
"*.md": {"{/*", "*/}"},
2221
},
2322
},
2423
{
@@ -33,13 +32,26 @@ TokenIgnores = (\$+[^\n$]+\$+)
3332
for _, c := range cases {
3433
t.Run(c.description, func(t *testing.T) {
3534
uCfg, err := shadowLoad([]byte(c.body))
36-
assert.NoError(t, err)
35+
if err != nil {
36+
t.Fatal(err)
37+
}
38+
3739
conf, err := NewConfig(&CLIFlags{})
38-
assert.NoError(t, err)
40+
if err != nil {
41+
t.Fatal(err)
42+
}
43+
3944
_, err = processConfig(uCfg, conf, false)
40-
assert.NoError(t, err)
45+
if err != nil {
46+
t.Fatal(err)
47+
}
48+
4149
actual := conf.CommentDelimiters
42-
assert.Equal(t, c.expected, actual)
50+
for k, v := range c.expected {
51+
if actual[k] != v {
52+
t.Errorf("expected %v, but got %v", v, actual[k])
53+
}
54+
}
4355
})
4456
}
4557
}
@@ -86,11 +98,19 @@ CommentDelimiters = "{/*"
8698
for _, c := range cases {
8799
t.Run(c.description, func(t *testing.T) {
88100
uCfg, err := shadowLoad([]byte(c.body))
89-
assert.NoError(t, err)
101+
if err != nil {
102+
t.Fatal(err)
103+
}
104+
90105
conf, err := NewConfig(&CLIFlags{})
91-
assert.NoError(t, err)
106+
if err != nil {
107+
t.Fatal(err)
108+
}
109+
92110
_, err = processConfig(uCfg, conf, false)
93-
assert.ErrorContains(t, err, c.expectedErr)
111+
if !strings.Contains(err.Error(), c.expectedErr) {
112+
t.Errorf("expected %v, but got %v", c.expectedErr, err.Error())
113+
}
94114
})
95115
}
96116
}

internal/lint/html_test.go

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

77
"github.com/errata-ai/vale/v3/internal/core"
8-
"github.com/stretchr/testify/assert"
98
)
109

1110
func Test_applyPatterns(t *testing.T) {
@@ -20,7 +19,7 @@ func Test_applyPatterns(t *testing.T) {
2019
description: "MDX comment in markdown, custom comment delimiter",
2120
conf: core.Config{
2221
CommentDelimiters: map[string][2]string{
23-
".md": [2]string{"{/*", "*/}"},
22+
".md": {"{/*", "*/}"},
2423
},
2524
},
2625
exts: extensionConfig{".md", ".md"},
@@ -74,7 +73,7 @@ This is the intro pagragraph.
7473
description: "multiline MDX comment in markdown, custom comment delimiter",
7574
conf: core.Config{
7675
CommentDelimiters: map[string][2]string{
77-
".md": [2]string{"{/*", "*/}"},
76+
".md": {"{/*", "*/}"},
7877
},
7978
},
8079
exts: extensionConfig{".md", ".md"},
@@ -108,7 +107,7 @@ This is a comment
108107
content: "Call \\c func to start the process.",
109108
conf: core.Config{
110109
TokenIgnores: map[string][]string{
111-
"*.cc": []string{`(\\c \w+)`},
110+
"*.cc": {`(\\c \w+)`},
112111
},
113112
Formats: map[string]string{
114113
"cc": "md",
@@ -122,8 +121,11 @@ This is a comment
122121
for _, c := range cases {
123122
t.Run(c.description, func(t *testing.T) {
124123
s, err := applyPatterns(&c.conf, c.exts, c.content)
125-
assert.NoError(t, err)
126-
assert.Equal(t, c.expected, s)
124+
if err != nil {
125+
t.Fatalf("applyPatterns returned an error: %s", err)
126+
} else if s != c.expected {
127+
t.Fatalf("Expected '%s', but got '%s'", c.expected, s)
128+
}
127129
})
128130
}
129131
}
@@ -140,7 +142,7 @@ func Test_applyPatterns_errors(t *testing.T) {
140142
description: "only one delimiter",
141143
conf: core.Config{
142144
CommentDelimiters: map[string][2]string{
143-
".md": [2]string{"{/*", ""},
145+
".md": {"{/*", ""},
144146
},
145147
},
146148
exts: extensionConfig{".md", ".md"},
@@ -159,7 +161,9 @@ This is the intro pagragraph.
159161
for _, c := range cases {
160162
t.Run(c.description, func(t *testing.T) {
161163
_, err := applyPatterns(&c.conf, c.exts, c.content)
162-
assert.ErrorContains(t, err, c.expectedErr)
164+
if !strings.Contains(err.Error(), c.expectedErr) {
165+
t.Fatalf("Expected '%s', but got '%s'", c.expectedErr, err.Error())
166+
}
163167
})
164168
}
165169
}

0 commit comments

Comments
 (0)