]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/config/templates_test.go
tests: add and use testutil package to reduce duplication
[safcm/safcm.git] / cmd / safcm / config / templates_test.go
index 8097af7312f3891ea2626f435ff4a3933d4cbcef..36b53dc87cd3755572fea831ab4b742113afe235 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 TestLoadTemplates(t *testing.T) {
@@ -252,14 +250,8 @@ This is GNU/Linux host
                        err = LoadTemplates(tc.group, files,
                                host, groups, allHosts, allGroups)
 
-                       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)
                })
        }
 }