2665ac1dee
CI / docker (push) Failing after 10s
Resolve public_base_url at SignURL time so admin settings apply without restart. Co-authored-by: Cursor <cursoragent@cursor.com>
25 lines
661 B
Go
25 lines
661 B
Go
package imagestore
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestSignURLUsesDynamicPublicBase(t *testing.T) {
|
|
current := "http://localhost:8293"
|
|
store := New(nil, t.TempDir(), func() string { return current }, "test-key", time.Hour)
|
|
|
|
if got := store.SignURL("img-1"); !hasPrefix(got, "http://localhost:8293/files/img-1") {
|
|
t.Fatalf("unexpected url: %s", got)
|
|
}
|
|
|
|
current = "https://gateway.example.com"
|
|
if got := store.SignURL("img-2"); !hasPrefix(got, "https://gateway.example.com/files/img-2") {
|
|
t.Fatalf("expected updated base url, got: %s", got)
|
|
}
|
|
}
|
|
|
|
func hasPrefix(s, prefix string) bool {
|
|
return len(s) >= len(prefix) && s[:len(prefix)] == prefix
|
|
}
|