This commit is contained in:
ponzischeme89
2026-08-11 15:18:26 +12:00
parent 594159c0ae
commit 5e5849f985
33 changed files with 1143 additions and 241 deletions
+35
View File
@@ -38,6 +38,41 @@ func TestBearerTokenSources(t *testing.T) {
})
}
func TestWriteUpstreamErrorPreservesRateLimitDelay(t *testing.T) {
s := &Server{}
rec := httptest.NewRecorder()
s.writeUpstreamError(
context.Background(),
rec,
&emby.APIError{StatusCode: http.StatusTooManyRequests, RetryAfter: "37"},
"could not reach emby",
)
if rec.Code != http.StatusTooManyRequests {
t.Fatalf("status = %d, want 429", rec.Code)
}
if got := rec.Header().Get("Retry-After"); got != "37" {
t.Fatalf("Retry-After = %q, want 37", got)
}
}
func TestWriteUpstreamErrorDefaultsMissingRateLimitDelay(t *testing.T) {
s := &Server{}
rec := httptest.NewRecorder()
s.writeUpstreamError(
context.Background(),
rec,
&emby.APIError{StatusCode: http.StatusTooManyRequests},
"could not reach emby",
)
if got := rec.Header().Get("Retry-After"); got != "60" {
t.Fatalf("Retry-After = %q, want 60", got)
}
}
func TestHashTokenIsStable(t *testing.T) {
a, b := hashToken("token"), hashToken("token")
if string(a) != string(b) {