chore: formatting

This commit is contained in:
2026-05-10 19:16:58 +02:00
parent 3befcc7cee
commit be9fbe0f64
2 changed files with 74 additions and 66 deletions

View File

@@ -11,43 +11,43 @@ func TestDecodeSourceURL(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
name string name string
encoded string encoded string
want string want string
}{ }{
{ {
name: "empty returns empty", name: "empty returns empty",
encoded: "", encoded: "",
want: "", want: "",
}, },
{ {
name: "with double prefix stripped", name: "with double prefix stripped",
encoded: "--example.com/video.mp4", encoded: "--example.com/video.mp4",
want: "example.com/video.mp4", want: "example.com/video.mp4",
}, },
{ {
name: "hex substitution", name: "hex substitution",
encoded: "7aexample", encoded: "7aexample",
want: "Bexample", want: "Bexample",
}, },
{ {
name: "mixed substitution", name: "mixed substitution",
encoded: "79url7a01", encoded: "79url7a01",
want: "AurlB9", want: "AurlB9",
}, },
{ {
name: "clock replacement", name: "clock replacement",
encoded: "/clock", encoded: "/clock",
want: "/clock.json", want: "/clock.json",
}, },
{ {
name: "no clock replacement if already json", name: "no clock replacement if already json",
encoded: "/clock.json", encoded: "/clock.json",
want: "/clock.json", want: "/clock.json",
}, },
{ {
name: "complex url", name: "complex url",
encoded: "--79stream7acom", encoded: "--79stream7acom",
want: "AstreamBcom", want: "AstreamBcom",
}, },
} }
@@ -67,37 +67,37 @@ func TestDetectStreamType(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
name string name string
url string url string
wantType string wantType string
}{ }{
{ {
name: "m3u8 extension", name: "m3u8 extension",
url: "https://example.com/video.m3u8", url: "https://example.com/video.m3u8",
wantType: "m3u8", wantType: "m3u8",
}, },
{ {
name: "master m3u8", name: "master m3u8",
url: "https://example.com/master.m3u8", url: "https://example.com/master.m3u8",
wantType: "m3u8", wantType: "m3u8",
}, },
{ {
name: "mp4 extension", name: "mp4 extension",
url: "https://example.com/video.mp4", url: "https://example.com/video.mp4",
wantType: "mp4", wantType: "mp4",
}, },
{ {
name: "unknown", name: "unknown",
url: "https://example.com/video.avi", url: "https://example.com/video.avi",
wantType: "unknown", wantType: "unknown",
}, },
{ {
name: "empty returns unknown", name: "empty returns unknown",
url: "", url: "",
wantType: "unknown", wantType: "unknown",
}, },
{ {
name: "case insensitive - M3U8", name: "case insensitive - M3U8",
url: "https://example.com/MASTER.M3U8", url: "https://example.com/MASTER.M3U8",
wantType: "m3u8", wantType: "m3u8",
}, },
@@ -118,42 +118,42 @@ func TestDetectEmbedType(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
name string name string
url string url string
wantType string wantType string
}{ }{
{ {
name: "streamwish", name: "streamwish",
url: "https://streamwish.com/e/abc123", url: "https://streamwish.com/e/abc123",
wantType: "embed", wantType: "embed",
}, },
{ {
name: "streamsb", name: "streamsb",
url: "https://streamsb.com/e/abc123", url: "https://streamsb.com/e/abc123",
wantType: "embed", wantType: "embed",
}, },
{ {
name: "mp4upload", name: "mp4upload",
url: "https://mp4upload.com/e/abc123", url: "https://mp4upload.com/e/abc123",
wantType: "embed", wantType: "embed",
}, },
{ {
name: "ok.ru", name: "ok.ru",
url: "https://ok.ru/video/123", url: "https://ok.ru/video/123",
wantType: "embed", wantType: "embed",
}, },
{ {
name: "gogoplay", name: "gogoplay",
url: "https://gogoplay.io/embed/123", url: "https://gogoplay.io/embed/123",
wantType: "embed", wantType: "embed",
}, },
{ {
name: "streamlare", name: "streamlare",
url: "https://streamlare.com/e/abc", url: "https://streamlare.com/e/abc",
wantType: "embed", wantType: "embed",
}, },
{ {
name: "unknown host", name: "unknown host",
url: "https://unknown.com/video", url: "https://unknown.com/video",
wantType: "unknown", wantType: "unknown",
}, },
@@ -195,7 +195,7 @@ func TestBuildSourceReferences(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
name string name string
rawURLs []any rawURLs []any
wantRefs []sourceReference wantRefs []sourceReference
}{ }{
@@ -300,9 +300,9 @@ func TestIsLikelyM3U8(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
name string name string
input []byte input []byte
want bool want bool
}{ }{
{ {
name: "valid m3u8", name: "valid m3u8",
@@ -316,7 +316,7 @@ func TestIsLikelyM3U8(t *testing.T) {
}, },
{ {
name: "empty", name: "empty",
input: []byte{}, input: []byte{},
want: false, want: false,
}, },
{ {
@@ -341,9 +341,9 @@ func TestIsLikelyMP4(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
name string name string
input []byte input []byte
want bool want bool
}{ }{
{ {
name: "ftyp at offset 4", name: "ftyp at offset 4",
@@ -362,8 +362,8 @@ func TestIsLikelyMP4(t *testing.T) {
}, },
{ {
name: "empty", name: "empty",
input: []byte{}, input: []byte{},
want: false, want: false,
}, },
} }
@@ -443,11 +443,19 @@ func TestAllAnimeClientImplementsInterfaces(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
_ interface{ Search(context.Context, string, string) ([]searchResult, error) } = &allAnimeClient{} _ interface {
_ interface{ GetEpisodeSources(context.Context, string, string, string) ([]StreamSource, error) } = &allAnimeClient{} Search(context.Context, string, string) ([]searchResult, error)
_ interface{ GetEpisodes(context.Context, string, string) ([]string, error) } = &allAnimeClient{} } = &allAnimeClient{}
_ interface{ GetAvailableEpisodes(context.Context, string) (AvailableEpisodes, error) } = &allAnimeClient{} _ interface {
GetEpisodeSources(context.Context, string, string, string) ([]StreamSource, error)
} = &allAnimeClient{}
_ interface {
GetEpisodes(context.Context, string, string) ([]string, error)
} = &allAnimeClient{}
_ interface {
GetAvailableEpisodes(context.Context, string) (AvailableEpisodes, error)
} = &allAnimeClient{}
) )
t.Log("allAnimeClient implements required interfaces") t.Log("allAnimeClient implements required interfaces")
} }

View File

@@ -149,7 +149,7 @@ func TestParseQualityValue(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
quality string quality string
want int want int
}{ }{
{ {
name: "auto returns 240", name: "auto returns 240",
@@ -198,10 +198,10 @@ func TestQualityMatches(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
name string name string
source string source string
target string target string
want bool want bool
}{ }{
{ {
name: "exact match", name: "exact match",
@@ -261,7 +261,7 @@ func TestQualityMatches(t *testing.T) {
func TestSourceQualityPriority(t *testing.T) { func TestSourceQualityPriority(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
name string name string
source string source string
target string target string
@@ -309,34 +309,34 @@ func TestSourceTypePriorityLookup(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
name string name string
sourceType string sourceType string
want int want int
}{ }{
{ {
name: "mp4 priority", name: "mp4 priority",
sourceType: "mp4", sourceType: "mp4",
want: 500, want: 500,
}, },
{ {
name: "m3u8 priority", name: "m3u8 priority",
sourceType: "m3u8", sourceType: "m3u8",
want: 450, want: 450,
}, },
{ {
name: "unknown uses fallback", name: "unknown uses fallback",
sourceType: "unknown", sourceType: "unknown",
want: 300, want: 300,
}, },
{ {
name: "embed fallback", name: "embed fallback",
sourceType: "embed", sourceType: "embed",
want: 100, want: 100,
}, },
{ {
name: "unrecognized uses fallback", name: "unrecognized uses fallback",
sourceType: "video", sourceType: "video",
want: 200, want: 200,
}, },
} }
@@ -355,27 +355,27 @@ func TestProviderPriorityLookup(t *testing.T) {
t.Parallel() t.Parallel()
tests := []struct { tests := []struct {
name string name string
provider string provider string
want int want int
}{ }{
{ {
name: "s-mp4", name: "s-mp4",
provider: "s-mp4", provider: "s-mp4",
want: 120, want: 120,
}, },
{ {
name: "default", name: "default",
provider: "default", provider: "default",
want: 115, want: 115,
}, },
{ {
name: "yt-mp4", name: "yt-mp4",
provider: "yt-mp4", provider: "yt-mp4",
want: 100, want: 100,
}, },
{ {
name: "unknown uses fallback", name: "unknown uses fallback",
provider: "unknown", provider: "unknown",
want: 60, want: 60,
}, },
@@ -488,4 +488,4 @@ func TestExtractDigits(t *testing.T) {
} }
}) })
} }
} }