This commit is contained in:
2026-05-30 09:24:42 +08:00
parent 6c3de4b2ef
commit e054f458bb
17 changed files with 533 additions and 78 deletions
+7 -2
View File
@@ -52,8 +52,13 @@ func Fetch(url string) ([]byte, error) {
}
req.Header.Set("User-Agent", "Mozilla/5.0 WINK/1.31.1 (AndroidTV/9) HlsWinkPlayer")
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
httpClient := http.Client{Timeout: 10 * time.Second}
transport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
httpClient := http.Client{
Timeout: 10 * time.Second,
Transport: transport,
}
resp, err := httpClient.Do(req)
if err != nil {
return nil, err
+51
View File
@@ -0,0 +1,51 @@
package utils
import (
"testing"
)
func TestMd5str(t *testing.T) {
tests := []struct {
input string
expected string
}{
{"hello", "5d41402abc4b2a76b9719d911017c592"},
{"", "d41d8cd98f00b204e9800998ecf8427e"},
{"http://example.com/stream", "a1b2c3d4e5f6"}, // just length check
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
got := Md5str(tt.input)
if len(got) != 32 {
t.Errorf("Md5str(%q) length = %d, want 32", tt.input, len(got))
}
})
}
}
func TestArrayUnique(t *testing.T) {
input := []string{"a", "b", "a", "c", "b"}
expected := []string{"a", "b", "c"}
got := ArrayUnique(input)
if len(got) != len(expected) {
t.Errorf("ArrayUnique length = %d, want %d", len(got), len(expected))
}
seen := make(map[string]bool)
for _, v := range got {
if seen[v] {
t.Errorf("ArrayUnique returned duplicate: %s", v)
}
seen[v] = true
}
}
func TestExpandPath(t *testing.T) {
got, err := ExpandPath("/tmp/test.txt")
if err != nil {
t.Fatalf("ExpandPath error: %v", err)
}
if got == "" {
t.Error("ExpandPath returned empty string")
}
}