@@ -13,6 +13,7 @@ import (
1313 "github.com/alvarorichard/Goanime/internal/util"
1414 "github.com/stretchr/testify/assert"
1515 "github.com/stretchr/testify/require"
16+ "golang.org/x/term"
1617)
1718
1819func TestIsAnimeFireVideoAPIURL (t * testing.T ) {
@@ -79,24 +80,24 @@ func TestSafePartPath(t *testing.T) {
7980
8081 t .Run ("valid" , func (t * testing.T ) {
8182 t .Parallel ()
82- got , err := safePartPath ("/tmp/video.mp4" , 1 )
83+ got , err := safePartPath (filepath . FromSlash ( "/tmp/video.mp4" ) , 1 )
8384 require .NoError (t , err )
84- assert .Equal (t , "/tmp/video.mp4.part1" , got )
85+ assert .Equal (t , filepath . FromSlash ( "/tmp/video.mp4.part1" ) , got )
8586 })
8687
8788 t .Run ("subdir ok" , func (t * testing.T ) {
8889 t .Parallel ()
89- got , err := safePartPath ("/tmp/sub/video.mp4" , 7 )
90+ got , err := safePartPath (filepath . FromSlash ( "/tmp/sub/video.mp4" ) , 7 )
9091 require .NoError (t , err )
9192 assert .Contains (t , got , "video.mp4.part7" )
9293 })
9394
9495 t .Run ("part embedded in dir name still resolves correctly" , func (t * testing.T ) {
9596 t .Parallel ()
9697 // Use a path whose basename uniquely identifies the part file.
97- got , err := safePartPath ("/tmp/dir.with.dots/video.mp4" , 0 )
98+ got , err := safePartPath (filepath . FromSlash ( "/tmp/dir.with.dots/video.mp4" ) , 0 )
9899 require .NoError (t , err )
99- assert .Equal (t , "/tmp/dir.with.dots/video.mp4.part0" , got )
100+ assert .Equal (t , filepath . FromSlash ( "/tmp/dir.with.dots/video.mp4.part0" ) , got )
100101 })
101102}
102103
@@ -586,8 +587,8 @@ func TestHandleBatchDownloadRange_AllEpisodesAlreadyDownloaded(t *testing.T) {
586587 // handleExistingEpisodes opens an interactive fuzzy finder. Outside a TTY
587588 // it errors on Linux but blocks indefinitely on Windows (tcell winTty
588589 // getConsoleInput syscall), which deadlocks CI. Skip when no TTY.
589- if os .Getenv ("CI" ) != "" {
590- t .Skip ("Skipping interactive fuzzy-finder test in CI (no TTY available) " )
590+ if os .Getenv ("CI" ) != "" || ! term . IsTerminal ( int ( os . Stdin . Fd ())) {
591+ t .Skip ("Skipping interactive fuzzy-finder test: requires a real TTY" )
591592 }
592593 util .InitLogger ()
593594 SetAnimeName ("HandleBatchRangeAllExistingTest" , 1 )
@@ -629,8 +630,8 @@ func TestHandleExistingEpisodes_WithDownloadedFilesEntersFuzzyFinder(t *testing.
629630 // handleExistingEpisodes opens an interactive fuzzy finder. Outside a TTY
630631 // it errors on Linux but blocks indefinitely on Windows (tcell winTty
631632 // getConsoleInput syscall), which deadlocks CI. Skip when no TTY.
632- if os .Getenv ("CI" ) != "" {
633- t .Skip ("Skipping interactive fuzzy-finder test in CI (no TTY available) " )
633+ if os .Getenv ("CI" ) != "" || ! term . IsTerminal ( int ( os . Stdin . Fd ())) {
634+ t .Skip ("Skipping interactive fuzzy-finder test: requires a real TTY" )
634635 }
635636 SetAnimeName ("HandleExistingDownloadedTest" , 1 )
636637 t .Cleanup (func () { SetAnimeName ("" , 0 ) })
@@ -655,8 +656,8 @@ func TestAskAndPlayDownloadedEpisode_WithDownloadedFilesEntersFuzzyFinder(t *tes
655656 // askAndPlayDownloadedEpisode opens an interactive fuzzy finder. Outside a
656657 // TTY it errors on Linux but blocks indefinitely on Windows (tcell winTty
657658 // getConsoleInput syscall), which deadlocks CI. Skip when no TTY.
658- if os .Getenv ("CI" ) != "" {
659- t .Skip ("Skipping interactive fuzzy-finder test in CI (no TTY available) " )
659+ if os .Getenv ("CI" ) != "" || ! term . IsTerminal ( int ( os . Stdin . Fd ())) {
660+ t .Skip ("Skipping interactive fuzzy-finder test: requires a real TTY" )
660661 }
661662 SetAnimeName ("AskAndPlayDownloadedExistingTest" , 1 )
662663 t .Cleanup (func () { SetAnimeName ("" , 0 ) })
0 commit comments