}
for _, tc := range tests {
+ t.Run(tc.name, func(t *testing.T) {
// Create separate test directory for each test case
path := filepath.Join(cwd, "testdata", tc.name)
err = os.Mkdir(path, 0700)
changes, err := handle(tc.path, tc.line, tc.create)
if !reflect.DeepEqual(tc.expChanges, changes) {
- t.Errorf("%s: changes: %s", tc.name,
+ t.Errorf("changes: %s",
cmp.Diff(tc.expChanges, changes))
}
// Ugly but the simplest way to compare errors (including nil)
if fmt.Sprintf("%s", err) != fmt.Sprintf("%s", tc.expErr) {
- t.Errorf("%s: err = %#v, want %#v",
- tc.name, err, tc.expErr)
+ t.Errorf("err = %#v, want %#v",
+ err, tc.expErr)
}
files, err := ft.WalkDir(path)
t.Fatal(err)
}
if !reflect.DeepEqual(tc.expFiles, files) {
- t.Errorf("%s: files: %s", tc.name,
+ t.Errorf("files: %s",
cmp.Diff(tc.expFiles, files))
}
+ })
}
if !t.Failed() {