55 "testing"
66
77 "github.com/errata-ai/vale/v3/internal/core"
8- "github.com/stretchr/testify/assert"
98)
109
1110func 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