package appapi

import "testing"

func TestValidateEffectMediaProxyURL(t *testing.T) {
	tests := []struct {
		name string
		url  string
		ok   bool
	}{
		{
			name: "mp4 media host",
			url:  "https://media.haiyihy.com/admin/files/1/20260602/file.mp4?sign=1",
			ok:   true,
		},
		{
			name: "svga media host",
			url:  "https://media.haiyihy.com/admin/files/1/20260602/file.svga",
			ok:   true,
		},
		{
			name: "pag media host",
			url:  "https://media.haiyihy.com/admin/files/1/20260602/file.pag?sign=1",
			ok:   true,
		},
		{
			name: "reject http",
			url:  "http://media.haiyihy.com/admin/files/1/file.svga",
			ok:   false,
		},
		{
			name: "reject untrusted host",
			url:  "https://example.com/admin/files/1/file.svga",
			ok:   false,
		},
		{
			name: "reject regular image",
			url:  "https://media.haiyihy.com/admin/files/1/file.png",
			ok:   false,
		},
	}

	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			_, _, ok := validateEffectMediaProxyURL(test.url)
			if ok != test.ok {
				t.Fatalf("ok mismatch: got=%t want=%t", ok, test.ok)
			}
		})
	}
}
