diff --git a/internal/uploads/intake_busy_test.go b/internal/uploads/intake_busy_test.go new file mode 100644 index 0000000..f895af5 --- /dev/null +++ b/internal/uploads/intake_busy_test.go @@ -0,0 +1,31 @@ +package uploads_test + +import ( + "context" + "errors" + "strings" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "git.d-ma.be/mathias/tapir/internal/domain" + "git.d-ma.be/mathias/tapir/internal/uploads" +) + +// A full queue is the user's to retry, not a server fault: a typed rejection, the row +// failed honestly, the audio removed (adversarial review F6). + +func TestAccept_AFullQueueIsABusyRejectionNotAServerErrorAndLeavesNothingBehind(t *testing.T) { + r := newRig(t) + r.sub.err = uploads.ErrQueueFull + + _, err := r.in.Accept(context.Background(), "user-1", "t", strings.NewReader("data")) + + var rej *uploads.RejectError + require.True(t, errors.As(err, &rej), "a full queue must be a rejection the web layer can answer with 429: %v", err) + assert.Equal(t, uploads.ReasonBusy, rej.Reason) + assert.Contains(t, rej.Message, "waiting") + assert.Equal(t, domain.UploadErrBusy, r.st.failed["up-1"], "the row must not sit queued: that is the stuck spinner") + assert.Empty(t, r.tmpFiles(t), "the audio is deleted") +}