X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=cmd%2Fsafcm-remote%2Fsync%2Fcommands_test.go;h=eb0cc0ba050df313cdd29d59155792fdbb079f13;hb=992eaae7fec45c2d58fff89d1bc0ae920a899296;hp=aeeea32f0ce2233ad281f755312024e232beda8a;hpb=f2f2bc47e8729548f3c10117f7f008b547c4afc5;p=safcm%2Fsafcm.git diff --git a/cmd/safcm-remote/sync/commands_test.go b/cmd/safcm-remote/sync/commands_test.go index aeeea32..eb0cc0b 100644 --- a/cmd/safcm-remote/sync/commands_test.go +++ b/cmd/safcm-remote/sync/commands_test.go @@ -29,7 +29,12 @@ import ( ) func TestSyncCommands(t *testing.T) { + exe, err := os.Executable() + if err != nil { + t.Fatal(err) + } env := append(os.Environ(), + "SAFCM_HELPER="+exe, "SAFCM_GROUPS=all group1 group2 host.example.org", "SAFCM_GROUP_all=all", "SAFCM_GROUP_group1=group1", @@ -492,9 +497,9 @@ func TestSyncCommands(t *testing.T) { } for _, tc := range tests { + t.Run(tc.name, func(t *testing.T) { s, res := prepareSync(tc.req, &testRunner{ t: t, - name: tc.name, expCmds: tc.expCmds, resStdout: tc.stdout, resStderr: tc.stderr, @@ -505,18 +510,19 @@ func TestSyncCommands(t *testing.T) { 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("%s: err = %#v, want %#v", - tc.name, err, tc.expErr) + t.Errorf("err = %#v, want %#v", + err, tc.expErr) } dbg := res.Wait() if !reflect.DeepEqual(tc.expResp, s.resp) { - t.Errorf("%s: resp: %s", tc.name, + t.Errorf("resp: %s", cmp.Diff(tc.expResp, s.resp)) } if !reflect.DeepEqual(tc.expDbg, dbg) { - t.Errorf("%s: dbg: %s", tc.name, + t.Errorf("dbg: %s", cmp.Diff(tc.expDbg, dbg)) } + }) } }