Skip to content

Commit ea8efa0

Browse files
committed
ossvc: imp code
1 parent 2ba0269 commit ea8efa0

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

internal/ossvc/defaultmanager_internal_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ func TestManager_Status_unixSystemV(t *testing.T) {
132132
// newTestSvc creates a new *testService with all methods set to panic, sets it
133133
// in the chosen system, and returns it. The caller can then set the desired
134134
// behavior of the service via overriding its methods.
135-
func newTestSvc(t *testing.T) (svc *testService) {
136-
t.Helper()
135+
func newTestSvc(tb testing.TB) (svc *testService) {
136+
tb.Helper()
137137

138138
svc = &testService{
139139
OnRun: func() (err error) { panic(testutil.UnexpectedCall()) },

internal/ossvc/service_openbsd.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,20 +324,24 @@ func (s *openbsdRunComService) runCom(cmd string) (out string, err error) {
324324
}
325325

326326
stdoutBuf := bytes.Buffer{}
327+
stderrBuf := bytes.Buffer{}
328+
327329
// TODO(s.chzhen): Pass context.
328330
err = executil.Run(context.TODO(), s.cmdCons, &executil.CommandConfig{
329-
Stderr: &stdoutBuf,
331+
Stderr: &stderrBuf,
330332
Stdout: ioutil.NewTruncatedWriter(&stdoutBuf, aghos.MaxCmdOutputSize),
331333
Path: scriptPath,
332334
Args: []string{cmd},
333335
})
334-
if errors.Is(err, os.ErrNotExist) {
335-
// TODO(e.burkov): It's possible that os.ErrNotExist is caused by
336-
// something different than the service script's non-existence.
336+
337+
switch {
338+
case errors.Is(err, os.ErrNotExist):
337339
return "", service.ErrNotInstalled
340+
case err != nil:
341+
return stderrBuf.String(), err
338342
}
339343

340-
return stdoutBuf.String(), err
344+
return stdoutBuf.String(), nil
341345
}
342346

343347
// Status implements service.Service interface for *openbsdRunComService.

0 commit comments

Comments
 (0)