diff --git a/cmd/tapir/uploads_test.go b/cmd/tapir/uploads_test.go index a18c02e..7e95a7a 100644 --- a/cmd/tapir/uploads_test.go +++ b/cmd/tapir/uploads_test.go @@ -12,6 +12,7 @@ import ( "git.d-ma.be/mathias/tapir/internal/config" "git.d-ma.be/mathias/tapir/internal/domain" + "git.d-ma.be/mathias/tapir/internal/web" ) // fakeUploadsStore satisfies the store surface buildUploads needs, and counts the @@ -125,3 +126,31 @@ func TestBuildUploads_RemovesAudioLeftBehindByACrash(t *testing.T) { _, err = os.Stat(unrelated) assert.NoError(t, err, "only our own spool files are removed") } + +func TestWireUploads_SetsEverythingTheWebAppNeedsForUploadsAndChat(t *testing.T) { + cfg := uploadCfg(t, true) + cfg.UploadMaxDuration = 90 * 60 * 1e9 + cfg.MaxUploadedTranscriptChars = 90000 + cfg.UploadChatModel = "iguana/gemma4-26b" + in, _, err := buildUploads(context.Background(), cfg, &fakeUploadsStore{}, quietLog()) + require.NoError(t, err) + app := &web.App{} + + wireUploads(app, cfg, in) + + assert.NotNil(t, app.Uploads) + assert.Equal(t, cfg.UploadMaxBytes, app.UploadLimits.MaxBytes, "the form states the limits Intake enforces") + assert.Equal(t, cfg.UploadMaxDuration, app.UploadLimits.MaxDuration) + assert.Equal(t, 90000, app.UploadChatMaxChars, + "without this the chat would use the 18,000-char caption default and cut an hour to its first third") + assert.Equal(t, "iguana/gemma4-26b", app.UploadChatModel) +} + +func TestWireUploads_NilIntakeLeavesTheAppUntouched(t *testing.T) { + app := &web.App{} + + wireUploads(app, uploadCfg(t, false), nil) + + assert.Nil(t, app.Uploads, "a nil *Intake must not become a non-nil interface that mounts the routes") + assert.Zero(t, app.UploadChatMaxChars) +}