X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm%2Fconfig%2Ftriggers_test.go;h=43c3a557882255e870a737ecd9c43ccc7b012368;hb=3473766d8afb07cb0685694656947883cbbd1138;hp=a27ec6a50902be9d55cfe94147e148540bdd39f5;hpb=f2f2bc47e8729548f3c10117f7f008b547c4afc5;p=safcm%2Fsafcm.git diff --git a/cmd/safcm/config/triggers_test.go b/cmd/safcm/config/triggers_test.go index a27ec6a..43c3a55 100644 --- a/cmd/safcm/config/triggers_test.go +++ b/cmd/safcm/config/triggers_test.go @@ -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) { @@ -133,23 +131,17 @@ This is FreeBSD host } for _, tc := range tests { - // Use LoadFiles() so we work on real data and don't make any - // mistakes generating it - files, err := LoadFiles(tc.group) - if err != nil { - t.Fatalf("%s: err = %#v, want nil", - tc.group, err) - } - err = LoadTriggers(tc.group, files) + t.Run(tc.group, func(t *testing.T) { + // Use LoadFiles() so we work on real data and don't + // make any mistakes generating it + files, err := LoadFiles(tc.group) + if err != nil { + t.Fatalf("err = %#v, want nil", err) + } + err = LoadTriggers(tc.group, files) - if !reflect.DeepEqual(tc.exp, files) { - t.Errorf("%s: res: %s", tc.group, - 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("%s: err = %#v, want %#v", - tc.group, err, tc.expErr) - } + testutil.AssertEqual(t, "res", files, tc.exp) + testutil.AssertErrorEqual(t, "err", err, tc.expErr) + }) } }