@@ -11,7 +11,6 @@ import (
1111)
1212
1313func TestGlobal_DefaultNotInitialized (t * testing.T ) {
14- // Reset global state for this test
1514 old := defaultService .Swap (nil )
1615 defer func () {
1716 if old != nil {
@@ -21,13 +20,13 @@ func TestGlobal_DefaultNotInitialized(t *testing.T) {
2120
2221 assert .Nil (t , Default ())
2322
24- _ , err := Start (context .Background (), "echo" , "test" )
25- assert .ErrorIs (t , err , ErrServiceNotInitialized )
23+ r := Start (context .Background (), "echo" , "test" )
24+ assert .False (t , r . OK )
2625
27- _ , err = Run (context .Background (), "echo" , "test" )
28- assert .ErrorIs (t , err , ErrServiceNotInitialized )
26+ r = Run (context .Background (), "echo" , "test" )
27+ assert .False (t , r . OK )
2928
30- _ , err = Get ("proc-1" )
29+ _ , err : = Get ("proc-1" )
3130 assert .ErrorIs (t , err , ErrServiceNotInitialized )
3231
3332 assert .Nil (t , List ())
@@ -36,11 +35,11 @@ func TestGlobal_DefaultNotInitialized(t *testing.T) {
3635 err = Kill ("proc-1" )
3736 assert .ErrorIs (t , err , ErrServiceNotInitialized )
3837
39- _ , err = StartWithOptions (context .Background (), RunOptions {Command : "echo" })
40- assert .ErrorIs (t , err , ErrServiceNotInitialized )
38+ r = StartWithOptions (context .Background (), RunOptions {Command : "echo" })
39+ assert .False (t , r . OK )
4140
42- _ , err = RunWithOptions (context .Background (), RunOptions {Command : "echo" })
43- assert .ErrorIs (t , err , ErrServiceNotInitialized )
41+ r = RunWithOptions (context .Background (), RunOptions {Command : "echo" })
42+ assert .False (t , r . OK )
4443}
4544
4645func newGlobalTestService (t * testing.T ) * Service {
@@ -62,7 +61,6 @@ func TestGlobal_SetDefault(t *testing.T) {
6261 }()
6362
6463 svc := newGlobalTestService (t )
65-
6664 err := SetDefault (svc )
6765 require .NoError (t , err )
6866 assert .Equal (t , svc , Default ())
@@ -83,7 +81,6 @@ func TestGlobal_ConcurrentDefault(t *testing.T) {
8381 }()
8482
8583 svc := newGlobalTestService (t )
86-
8784 err := SetDefault (svc )
8885 require .NoError (t , err )
8986
@@ -146,7 +143,6 @@ func TestGlobal_ConcurrentOperations(t *testing.T) {
146143 }()
147144
148145 svc := newGlobalTestService (t )
149-
150146 err := SetDefault (svc )
151147 require .NoError (t , err )
152148
@@ -158,10 +154,10 @@ func TestGlobal_ConcurrentOperations(t *testing.T) {
158154 wg .Add (1 )
159155 go func () {
160156 defer wg .Done ()
161- proc , err := Start (context .Background (), "echo" , "concurrent" )
162- if err == nil {
157+ r := Start (context .Background (), "echo" , "concurrent" )
158+ if r . OK {
163159 procMu .Lock ()
164- processes = append (processes , proc )
160+ processes = append (processes , r . Value .( * Process ) )
165161 procMu .Unlock ()
166162 }
167163 }()
@@ -201,47 +197,44 @@ func TestGlobal_ConcurrentOperations(t *testing.T) {
201197
202198func TestGlobal_StartWithOptions (t * testing.T ) {
203199 svc , _ := newTestService (t )
204-
205200 old := defaultService .Swap (svc )
206201 defer func () {
207202 if old != nil {
208203 defaultService .Store (old )
209204 }
210205 }()
211206
212- proc , err := StartWithOptions (context .Background (), RunOptions {
207+ r := StartWithOptions (context .Background (), RunOptions {
213208 Command : "echo" ,
214209 Args : []string {"with" , "options" },
215210 })
216- require .NoError (t , err )
211+ require .True (t , r .OK )
212+ proc := r .Value .(* Process )
217213
218214 <- proc .Done ()
219-
220215 assert .Equal (t , 0 , proc .ExitCode )
221216 assert .Contains (t , proc .Output (), "with options" )
222217}
223218
224219func TestGlobal_RunWithOptions (t * testing.T ) {
225220 svc , _ := newTestService (t )
226-
227221 old := defaultService .Swap (svc )
228222 defer func () {
229223 if old != nil {
230224 defaultService .Store (old )
231225 }
232226 }()
233227
234- output , err := RunWithOptions (context .Background (), RunOptions {
228+ r := RunWithOptions (context .Background (), RunOptions {
235229 Command : "echo" ,
236230 Args : []string {"run" , "options" },
237231 })
238- require . NoError (t , err )
239- assert .Contains (t , output , "run options" )
232+ assert . True (t , r . OK )
233+ assert .Contains (t , r . Value .( string ) , "run options" )
240234}
241235
242236func TestGlobal_Running (t * testing.T ) {
243237 svc , _ := newTestService (t )
244-
245238 old := defaultService .Swap (svc )
246239 defer func () {
247240 if old != nil {
@@ -252,8 +245,9 @@ func TestGlobal_Running(t *testing.T) {
252245 ctx , cancel := context .WithCancel (context .Background ())
253246 defer cancel ()
254247
255- proc , err := Start (ctx , "sleep" , "60" )
256- require .NoError (t , err )
248+ r := Start (ctx , "sleep" , "60" )
249+ require .True (t , r .OK )
250+ proc := r .Value .(* Process )
257251
258252 running := Running ()
259253 assert .Len (t , running , 1 )
0 commit comments