]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/config/permissions_test.go
tests: add and use testutil package to reduce duplication
[safcm/safcm.git] / cmd / safcm / config / permissions_test.go
index ba1d505f9f019f314d7e02c80fa63790f298bf34..98b82b6ba877d0aaae02959384404a4f863815a6 100644 (file)
@@ -19,12 +19,10 @@ import (
        "fmt"
        "io/fs"
        "os"
-       "reflect"
        "testing"
 
-       "github.com/google/go-cmp/cmp"
-
        "ruderich.org/simon/safcm"
+       "ruderich.org/simon/safcm/testutil"
 )
 
 func TestLoadPermissions(t *testing.T) {
@@ -235,14 +233,8 @@ This is FreeBSD host
                        }
                        err = LoadPermissions(tc.group, files)
 
-                       if !reflect.DeepEqual(tc.exp, files) {
-                               t.Errorf("res: %s", cmp.Diff(tc.exp, files))
-                       }
-                       // Ugly but the simplest way to compare errors (including nil)
-                       if fmt.Sprintf("%s", err) != fmt.Sprintf("%s", tc.expErr) {
-                               t.Errorf("err = %#v, want %#v",
-                                       err, tc.expErr)
-                       }
+                       testutil.AssertEqual(t, "res", files, tc.exp)
+                       testutil.AssertErrorEqual(t, "err", err, tc.expErr)
                })
        }
 }