check / check (push) Failing after 0s
Accumulating milestone branch. One squashed commit per closed issue; `next` is kept green and mergeable to `main` at any time without notice. Landed so far: - `chore: update golangci-lint to v2.12.2 with canonical config` (#54) — canonical v2-schema `.golangci.yml`, pins bumped in `Dockerfile` and `script/bootstrap`, tree at `0 issues.`. Three behaviour deltas are recorded in that PR's body: `Cache.StoreVariant` takes a context, `MetadataStorage.Store` no longer leaks temp files on failure, and the `signing_key` too-short error text gained a `value too short:` prefix. Sequencing for the milestone is tracked in #103. Reviewed-on: #105 Co-authored-by: clawbot <clawbot@noreply.example.org>
53 lines
1008 B
Go
53 lines
1008 B
Go
package imgcache
|
|
|
|
import "testing"
|
|
|
|
func TestImageRequest_SourceURL_DefaultHTTPS(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
req := &ImageRequest{
|
|
SourceHost: testHostCDN,
|
|
SourcePath: testPathCat,
|
|
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) {
|
|
t.Parallel()
|
|
|
|
req := &ImageRequest{
|
|
SourceHost: "localhost:8080",
|
|
SourcePath: testPathCat,
|
|
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) {
|
|
t.Parallel()
|
|
|
|
req := &ImageRequest{
|
|
SourceHost: testHostCDN,
|
|
SourcePath: "/img.jpg",
|
|
AllowHTTP: false,
|
|
}
|
|
|
|
got := req.SourceURL()
|
|
if got != "https://cdn.example.com/img.jpg" {
|
|
t.Errorf("SourceURL() = %q, want https scheme", got)
|
|
}
|
|
}
|