Files
huangguo_server/common/media/h265_test.go
T
rootandClaude Opus 5 8679200f41 Initial commit
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 13:57:10 +08:00

46 lines
1.0 KiB
Go

package mediaService
import "testing"
func TestShouldUpdateH265URL(t *testing.T) {
tests := []struct {
name string
current string
incoming string
want bool
}{
{
name: "empty incoming does not erase existing URL",
current: "https://cdn.example.com/existing.m3u8",
incoming: "",
want: false,
},
{
name: "whitespace incoming does not erase existing URL",
current: "https://cdn.example.com/existing.m3u8",
incoming: " ",
want: false,
},
{
name: "same URL does not update",
current: "https://cdn.example.com/hevc.m3u8",
incoming: " https://cdn.example.com/hevc.m3u8 ",
want: false,
},
{
name: "new non-empty URL updates",
current: "",
incoming: "https://cdn.example.com/hevc.m3u8",
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := shouldUpdateH265URL(tt.current, tt.incoming); got != tt.want {
t.Fatalf("shouldUpdateH265URL() = %v, want %v", got, tt.want)
}
})
}
}