]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/sync_sync_test.go
config: permit "all" and host group in .InGroup of templates
[safcm/safcm.git] / cmd / safcm / sync_sync_test.go
index f3d046a23a0f4618525403fd1158239e8d149dca..31252936e663861f18aa352766ab43479540caae 100644 (file)
@@ -22,12 +22,10 @@ import (
        "log"
        "os"
        "path/filepath"
-       "reflect"
        "testing"
 
-       "github.com/google/go-cmp/cmp"
-
        "ruderich.org/simon/safcm"
+       "ruderich.org/simon/safcm/testutil"
 )
 
 func TestHostSyncReq(t *testing.T) {
@@ -95,7 +93,7 @@ func TestHostSyncReq(t *testing.T) {
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               Data:      []byte("Welcome to Host ONE\n\n\n\n"),
+                                               Data:      []byte("Welcome to Host ONE\n\n\n\n\n\nall\n\n\nhost1.example.org\n\n\n\n"),
                                        },
                                        "/etc/rc.local": &safcm.File{
                                                OrigGroup: "group",
@@ -193,7 +191,7 @@ func TestHostSyncReq(t *testing.T) {
                                                Mode:      0644,
                                                Uid:       -1,
                                                Gid:       -1,
-                                               Data:      []byte("Welcome to Host ONE\n\n\n\n"),
+                                               Data:      []byte("Welcome to Host ONE\n\n\n\n\n\nall\n\n\nhost1.example.org\n\n\n\n"),
                                        },
                                        "/etc/rc.local": &safcm.File{
                                                OrigGroup: "group",
@@ -470,21 +468,14 @@ func TestHostSyncReq(t *testing.T) {
                        }
 
                        res, err := s.hostSyncReq(tc.detected)
-                       if !reflect.DeepEqual(tc.exp, res) {
-                               t.Errorf("res: %s", cmp.Diff(tc.exp, res))
-                       }
-                       // 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", res, tc.exp)
+                       testutil.AssertErrorEqual(t, "err", err, tc.expErr)
 
                        close(ch)
                        <-done
-                       if !reflect.DeepEqual(tc.expEvents, events) {
-                               t.Errorf("events: %s",
-                                       cmp.Diff(tc.expEvents, events))
-                       }
+                       testutil.AssertEqual(t, "events",
+                               events, tc.expEvents)
                })
        }
 }