use context to stop main() jobs

use
This commit is contained in:
sentriz
2024-02-27 00:33:39 +00:00
parent a66463a68c
commit 02606087dc
6 changed files with 24 additions and 50 deletions

View File

@@ -1,6 +1,7 @@
package jukebox_test
import (
"context"
"errors"
"os"
"path/filepath"
@@ -193,8 +194,11 @@ func newJukebox(tb testing.TB) *jukebox.Jukebox {
sockPath := filepath.Join(tb.TempDir(), "mpv.sock")
ctx, cancel := context.WithCancel(context.Background())
j := jukebox.New()
err := j.Start(
ctx,
sockPath,
[]string{jukebox.MPVArg("--ao", "null")},
)
@@ -205,7 +209,7 @@ func newJukebox(tb testing.TB) *jukebox.Jukebox {
tb.Fatalf("start jukebox: %v", err)
}
tb.Cleanup(func() {
j.Quit()
cancel()
})
return j
}