test(cmd): wireUploads sets the budget and model, and never a typed-nil Intake (red)
I wired Uploads and UploadLimits in cmdServe but not UploadChatMaxChars: chat over a long recording would have silently used the 18,000-char caption default. A helper that main and the e2e test both call makes that a tested fact. Red: wireUploads is undefined. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
|||||||
|
|
||||||
"git.d-ma.be/mathias/tapir/internal/config"
|
"git.d-ma.be/mathias/tapir/internal/config"
|
||||||
"git.d-ma.be/mathias/tapir/internal/domain"
|
"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
|
// fakeUploadsStore satisfies the store surface buildUploads needs, and counts the
|
||||||
@@ -125,3 +126,31 @@ func TestBuildUploads_RemovesAudioLeftBehindByACrash(t *testing.T) {
|
|||||||
_, err = os.Stat(unrelated)
|
_, err = os.Stat(unrelated)
|
||||||
assert.NoError(t, err, "only our own spool files are removed")
|
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)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user