Enhance environment variable documentation and configuration
Format / gofmt (push) Successful in 5s
CI / Build (push) Successful in 12s
CI / Go Tests (push) Successful in 22s
Release Artifacts / Validate release tag (push) Successful in 1s
Release Artifacts / Build and release executables (push) Successful in 33s
Release Artifacts / Build and release Docker image (push) Successful in 3m10s
Format / gofmt (push) Successful in 5s
CI / Build (push) Successful in 12s
CI / Go Tests (push) Successful in 22s
Release Artifacts / Validate release tag (push) Successful in 1s
Release Artifacts / Build and release executables (push) Successful in 33s
Release Artifacts / Build and release Docker image (push) Successful in 3m10s
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -373,3 +373,49 @@ func min(a, b int) int {
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// Scratches larger than limits.raw_cache_max_size must stream from storage
|
||||
// (no full in-memory buffer) so multi-GiB downloads stay viable.
|
||||
func TestRawStreamsWhenLargerThanCache(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
payload := bytes.Repeat([]byte("Z"), 8*1024) // 8 KiB body
|
||||
handler := newTestHandler(t, testServerOptions{
|
||||
maxUploadBytes: int64(len(payload) * 2),
|
||||
defaultTTL: time.Hour,
|
||||
rateLimitEnable: false,
|
||||
rawCacheBytes: 1024, // smaller than payload => stream path
|
||||
})
|
||||
|
||||
createReq := httptest.NewRequest(http.MethodPost, "/api/scratch", bytes.NewReader(payload))
|
||||
createReq.Header.Set("Content-Type", "application/octet-stream")
|
||||
createReq.RemoteAddr = "127.0.0.1:7100"
|
||||
createRec := httptest.NewRecorder()
|
||||
handler.ServeHTTP(createRec, createReq)
|
||||
if createRec.Code != http.StatusCreated {
|
||||
t.Fatalf("create status = %d, want 201 body=%q", createRec.Code, createRec.Body.String())
|
||||
}
|
||||
|
||||
var created map[string]any
|
||||
if err := json.Unmarshal(createRec.Body.Bytes(), &created); err != nil {
|
||||
t.Fatalf("decode create payload: %v", err)
|
||||
}
|
||||
id, _ := created["id"].(string)
|
||||
if id == "" {
|
||||
t.Fatal("create payload missing id")
|
||||
}
|
||||
|
||||
rawReq := httptest.NewRequest(http.MethodGet, "/api/raw/"+id, nil)
|
||||
rawReq.RemoteAddr = "127.0.0.1:7101"
|
||||
rawRec := httptest.NewRecorder()
|
||||
handler.ServeHTTP(rawRec, rawReq)
|
||||
if rawRec.Code != http.StatusOK {
|
||||
t.Fatalf("raw status = %d, want 200", rawRec.Code)
|
||||
}
|
||||
if got := rawRec.Header().Get("Accept-Ranges"); got != "none" {
|
||||
t.Fatalf("Accept-Ranges = %q, want none (stream path)", got)
|
||||
}
|
||||
if got := rawRec.Body.Bytes(); !bytes.Equal(got, payload) {
|
||||
t.Fatalf("raw body len=%d, want %d (content mismatch or truncated)", len(got), len(payload))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user