mirror of
https://codeberg.org/scip/tablizer.git
synced 2025-12-17 04:30:56 +01:00
refactoring and gouncritic, 1st part
This commit is contained in:
@@ -34,7 +34,7 @@ func TestPrepareModeFlags(t *testing.T) {
|
||||
{Modeflag{O: true}, Orgtbl},
|
||||
{Modeflag{Y: true}, Yaml},
|
||||
{Modeflag{M: true}, Markdown},
|
||||
{Modeflag{}, Ascii},
|
||||
{Modeflag{}, ASCII},
|
||||
}
|
||||
|
||||
// FIXME: use a map for easier printing
|
||||
@@ -63,15 +63,15 @@ func TestPrepareSortFlags(t *testing.T) {
|
||||
{Sortmode{}, "string"},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
testname := fmt.Sprintf("PrepareSortFlags-expect-%s", tt.expect)
|
||||
for _, testdata := range tests {
|
||||
testname := fmt.Sprintf("PrepareSortFlags-expect-%s", testdata.expect)
|
||||
t.Run(testname, func(t *testing.T) {
|
||||
c := Config{}
|
||||
conf := Config{}
|
||||
|
||||
c.PrepareSortFlags(tt.flag)
|
||||
conf.PrepareSortFlags(testdata.flag)
|
||||
|
||||
if c.SortMode != tt.expect {
|
||||
t.Errorf("got: %s, expect: %s", c.SortMode, tt.expect)
|
||||
if conf.SortMode != testdata.expect {
|
||||
t.Errorf("got: %s, expect: %s", conf.SortMode, testdata.expect)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -86,15 +86,16 @@ func TestPreparePattern(t *testing.T) {
|
||||
{"[a-z", true},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
testname := fmt.Sprintf("PreparePattern-pattern-%s-wanterr-%t", tt.pattern, tt.wanterr)
|
||||
for _, testdata := range tests {
|
||||
testname := fmt.Sprintf("PreparePattern-pattern-%s-wanterr-%t",
|
||||
testdata.pattern, testdata.wanterr)
|
||||
t.Run(testname, func(t *testing.T) {
|
||||
c := Config{}
|
||||
conf := Config{}
|
||||
|
||||
err := c.PreparePattern(tt.pattern)
|
||||
err := conf.PreparePattern(testdata.pattern)
|
||||
|
||||
if err != nil {
|
||||
if !tt.wanterr {
|
||||
if !testdata.wanterr {
|
||||
t.Errorf("PreparePattern returned error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user