]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm/sync_sync_test.go
tests: add and use testutil package to reduce duplication
[safcm/safcm.git] / cmd / safcm / sync_sync_test.go
index f3d046a23a0f4618525403fd1158239e8d149dca..b5e8ce242b01c5e793da5702c24fb942d8bb034a 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) {
@@ -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)
                })
        }
 }