package imagerequest import "testing" func TestSource_URL_DefaultHTTPS(t *testing.T) { t.Parallel() source := Source{ Host: testHostCDN, Path: testPathCat, Query: "v=2", } got := source.URL(false).String() want := "https://cdn.example.com/photos/cat.jpg?v=2" if got != want { t.Errorf("URL() = %q, want %q", got, want) } } func TestSource_URL_AllowHTTP(t *testing.T) { t.Parallel() source := Source{ Host: "localhost:8080", Path: testPathCat, } got := source.URL(true).String() want := "http://localhost:8080/photos/cat.jpg" if got != want { t.Errorf("URL() = %q, want %q", got, want) } } func TestSource_URL_AllowHTTPFalse(t *testing.T) { t.Parallel() source := Source{ Host: testHostCDN, Path: "/img.jpg", } got := source.URL(false).String() if got != "https://cdn.example.com/img.jpg" { t.Errorf("URL() = %q, want https scheme", got) } }