X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm-remote%2Fsync%2Fservices_systemd_test.go;h=0460bb73c771ed6046c95097742a188f9186d64d;hb=6089e2fbed6bf995122f331ceffcfc8c7b9dda31;hp=df226fc85e00fae40dc06834e25deae3a1bce5e5;hpb=992eaae7fec45c2d58fff89d1bc0ae920a899296;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 df226fc..0460bb7 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) { @@ -508,30 +506,20 @@ LoadError= for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { - s, res := prepareSync(tc.req, &testRunner{ - t: t, - expCmds: tc.expCmds, - resStdout: tc.stdout, - resStderr: tc.stderr, - resError: tc.errors, - }) - - 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) - } - 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)) - } + s, res := prepareSync(tc.req, &testRunner{ + t: t, + expCmds: tc.expCmds, + resStdout: tc.stdout, + resStderr: tc.stderr, + resError: tc.errors, + }) + + err := s.syncServicesSystemd() + testutil.AssertErrorEqual(t, "err", err, tc.expErr) + dbg := res.Wait() + + testutil.AssertEqual(t, "resp", s.resp, tc.expResp) + testutil.AssertEqual(t, "dbg", dbg, tc.expDbg) }) } }