package imgcache import "testing" func TestImageRequest_SourceURL_DefaultHTTPS(t *testing.T) { req := &ImageRequest{ SourceHost: "cdn.example.com", SourcePath: "/photos/cat.jpg", SourceQuery: "v=2", } got := req.SourceURL() want := "https://cdn.example.com/photos/cat.jpg?v=2" if got != want { t.Errorf("SourceURL() = %q, want %q", got, want) } } func TestImageRequest_SourceURL_AllowHTTP(t *testing.T) { req := &ImageRequest{ SourceHost: "localhost:8080", SourcePath: "/photos/cat.jpg", AllowHTTP: true, } got := req.SourceURL() want := "http://localhost:8080/photos/cat.jpg" if got != want { t.Errorf("SourceURL() = %q, want %q", got, want) } } func TestImageRequest_SourceURL_AllowHTTPFalse(t *testing.T) { req := &ImageRequest{ SourceHost: "cdn.example.com", SourcePath: "/img.jpg", AllowHTTP: false, } got := req.SourceURL() if got != "https://cdn.example.com/img.jpg" { t.Errorf("SourceURL() = %q, want https scheme", got) } }