X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm-remote%2Fsync%2Fservices_systemd_test.go;h=e45e79050a17183ee4fe4cf5429ae7ec88a536eb;hb=b088bf0b7e872d0e6ba230d4e4b79625af4fb17e;hp=40dd2e0c4644b32bcf357690ae1e1cee4de95f03;hpb=4299c5d0946ecfa034e9eefe6b16e50bab94a820;p=safcm%2Fsafcm.git diff --git a/cmd/safcm-remote/sync/services_systemd_test.go b/cmd/safcm-remote/sync/services_systemd_test.go index 40dd2e0..e45e790 100644 --- a/cmd/safcm-remote/sync/services_systemd_test.go +++ b/cmd/safcm-remote/sync/services_systemd_test.go @@ -19,12 +19,10 @@ import ( "bytes" "fmt" "os/exec" - "reflect" "testing" - "github.com/google/go-cmp/cmp" - "ruderich.org/simon/safcm" + "ruderich.org/simon/safcm/testutil" ) func TestSyncServicesSystemd(t *testing.T) { @@ -41,7 +39,7 @@ func TestSyncServicesSystemd(t *testing.T) { }{ // NOTE: Also update MsgSyncResp in safcm test cases when - // changing anything here! + // changing the MsgSyncResp struct! { "no service change necessary", @@ -226,7 +224,7 @@ LoadError= nil, nil, nil, - []byte(`fake stderr`), + []byte("fake stderr"), }, []error{nil, nil, nil, nil}, []*exec.Cmd{&exec.Cmd{ @@ -423,7 +421,7 @@ LoadError= [][]byte{ nil, nil, - []byte(`fake stderr`), + []byte("fake stderr"), }, []error{ nil, @@ -517,21 +515,11 @@ LoadError= }) err := s.syncServicesSystemd() - // 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) }) } }