test(uploads): pin the idle bound an unset App resolves to (#56)
Round-2 gatekeeper finding: production never sets UploadIdleTimeout, so it
always runs the zero-means-default branch, and nothing asserted what that
branch resolved to (`idle = time.Hour` kept the suite green).
Extract the resolution into App.uploadIdleTimeout(), expose it via
export_test.go, and assert (&web.App{}) resolves to exactly 60s, a
negative value too, and a set value is honoured. Verified red against the
time.Hour mutant before implementing.
Rename the socket test to what it observes:
...AnUnsetIdleTimeoutDoesNotCutABodyWithSubSecondGaps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -121,9 +121,18 @@ func TestDefaultUploadIdleTimeoutIsSixtySeconds(t *testing.T) {
|
||||
require.Equal(t, 60*time.Second, web.DefaultUploadIdleTimeout)
|
||||
}
|
||||
|
||||
// With UploadIdleTimeout unset the default applies: a body with 100 ms gaps between reads is
|
||||
// accepted (a default in milliseconds or nanoseconds would cut it).
|
||||
func TestUploadPost_AnUnsetIdleTimeoutAppliesTheDefaultAndAcceptsABodyWithSubSecondGaps(t *testing.T) {
|
||||
// The bound an App actually resolves to, not the constant: production's App leaves
|
||||
// UploadIdleTimeout unset, so the zero value must resolve to exactly 60 s, and a set value
|
||||
// must be used as given.
|
||||
func TestAppUploadIdleTimeout_ResolvesUnsetToSixtySecondsAndHonoursASetValue(t *testing.T) {
|
||||
require.Equal(t, 60*time.Second, (&web.App{}).UploadIdleTimeoutForTest())
|
||||
require.Equal(t, 60*time.Second, (&web.App{UploadIdleTimeout: -time.Second}).UploadIdleTimeoutForTest())
|
||||
require.Equal(t, 300*time.Millisecond, (&web.App{UploadIdleTimeout: 300 * time.Millisecond}).UploadIdleTimeoutForTest())
|
||||
}
|
||||
|
||||
// With UploadIdleTimeout unset, a body with 100 ms gaps between reads is not cut (a resolved
|
||||
// bound in milliseconds or nanoseconds would cut it). The exact value is pinned above.
|
||||
func TestUploadPost_AnUnsetIdleTimeoutDoesNotCutABodyWithSubSecondGaps(t *testing.T) {
|
||||
addr := newIdleBoundServer(t, 0)
|
||||
body, ct := multipartBody(t, bytes.Repeat([]byte("a"), 1000))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user