test: v2 handler error paths (closed db), v1 scheme, rpm content-type/flag helpers

This commit is contained in:
2026-07-03 13:29:23 +10:00
parent 1842042241
commit 4ec3d7b59e
3 changed files with 178 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
package v1
import (
"crypto/tls"
"net/http"
"testing"
)
func TestScheme(t *testing.T) {
if got := scheme(&http.Request{TLS: &tls.ConnectionState{}}); got != "https" {
t.Errorf("TLS request scheme = %q, want https", got)
}
r := &http.Request{Header: http.Header{"X-Forwarded-Proto": {"https"}}}
if got := scheme(r); got != "https" {
t.Errorf("X-Forwarded-Proto scheme = %q, want https", got)
}
if got := scheme(&http.Request{Header: http.Header{}}); got != "http" {
t.Errorf("default scheme = %q, want http", got)
}
}