refactored and un-go-criticed

This commit is contained in:
2024-05-07 18:01:12 +02:00
parent 9e2e45715e
commit 473feff451
18 changed files with 262 additions and 188 deletions

View File

@@ -72,18 +72,18 @@ func TestPrepareColumns(t *testing.T) {
{"[a-z,4,5", []int{4, 5}, true}, // invalid regexp
}
for _, tt := range tests {
testname := fmt.Sprintf("PrepareColumns-%s-%t", tt.input, tt.wanterror)
for _, testdata := range tests {
testname := fmt.Sprintf("PrepareColumns-%s-%t", testdata.input, testdata.wanterror)
t.Run(testname, func(t *testing.T) {
conf := cfg.Config{Columns: tt.input}
conf := cfg.Config{Columns: testdata.input}
err := PrepareColumns(&conf, &data)
if err != nil {
if !tt.wanterror {
if !testdata.wanterror {
t.Errorf("got error: %v", err)
}
} else {
if !reflect.DeepEqual(conf.UseColumns, tt.exp) {
t.Errorf("got: %v, expected: %v", conf.UseColumns, tt.exp)
if !reflect.DeepEqual(conf.UseColumns, testdata.exp) {
t.Errorf("got: %v, expected: %v", conf.UseColumns, testdata.exp)
}
}
})