All checks were successful
check / check (push) Successful in 4s
Canonical v2-schema `.golangci.yml`, golangci-lint pins bumped to v2.12.2 in `Dockerfile` and `script/bootstrap`, and the tree brought to `0 issues.` under it. Three behaviour deltas: `Cache.StoreVariant` takes a context (cancelled requests skip the accounting row, recovered by reconciliation); `MetadataStorage.Store` no longer leaks `.tmp-*.json` on Write/Close/Rename failure (dead-defer bug fix); the `signing_key` too-short error text gained a `value too short:` prefix. Eviction-loop context cancellation deferred to #102.
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)
|
|
}
|
|
}
|