0.2.50
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user