]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm-remote/ainsl/ainsl_test.go
tests: use subtests
[safcm/safcm.git] / cmd / safcm-remote / ainsl / ainsl_test.go
index 25258ff0aeb65cb98acaff6b5512aebb807904db..e4d6b46ddebeecb8cd0906f9c0c6052b55acdcd2 100644 (file)
@@ -293,6 +293,7 @@ func TestHandle(t *testing.T) {
        }
 
        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)
@@ -310,13 +311,13 @@ func TestHandle(t *testing.T) {
 
                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)
@@ -324,9 +325,10 @@ func TestHandle(t *testing.T) {
                        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() {