]> ruderich.org/simon Gitweb - safcm/safcm.git/blobdiff - cmd/safcm-remote/sync/commands_test.go
tests: add and use testutil package to reduce duplication
[safcm/safcm.git] / cmd / safcm-remote / sync / commands_test.go
index 3c47c1757c6adf5f199dc4342a692127da263e03..142a2542a931d4191d56f0b5be641da6a2b00cd7 100644 (file)
@@ -20,12 +20,10 @@ import (
        "io/fs"
        "os"
        "os/exec"
-       "reflect"
        "testing"
 
-       "github.com/google/go-cmp/cmp"
-
        "ruderich.org/simon/safcm"
+       "ruderich.org/simon/safcm/testutil"
 )
 
 func TestSyncCommands(t *testing.T) {
@@ -508,21 +506,11 @@ func TestSyncCommands(t *testing.T) {
                        s.triggers = tc.triggers
 
                        err := s.syncCommands()
-                       // 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.AssertErrorEqual(t, "err", err, tc.expErr)
                        dbg := res.Wait()
 
-                       if !reflect.DeepEqual(tc.expResp, s.resp) {
-                               t.Errorf("resp: %s",
-                                       cmp.Diff(tc.expResp, s.resp))
-                       }
-                       if !reflect.DeepEqual(tc.expDbg, dbg) {
-                               t.Errorf("dbg: %s",
-                                       cmp.Diff(tc.expDbg, dbg))
-                       }
+                       testutil.AssertEqual(t, "resp", s.resp, tc.expResp)
+                       testutil.AssertEqual(t, "dbg", dbg, tc.expDbg)
                })
        }
 }