]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/config/triggers_test.go
tests: add and use testutil package to reduce duplication
[safcm/safcm.git] / cmd / safcm / config / triggers_test.go
index 7de0322895ba3e0140cd83a5adacd76fc8f109b4..43c3a557882255e870a737ecd9c43ccc7b012368 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 TestLoadTriggers(t *testing.T) {
@@ -142,14 +140,8 @@ This is FreeBSD host
                        }
                        err = LoadTriggers(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)
                })
        }
 }