test(cmd): start-up removes spooled audio left by a crash (red)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -104,3 +104,24 @@ func TestBuildUploads_EnabledWithoutAGatewayIsAnError(t *testing.T) {
|
|||||||
|
|
||||||
assert.Error(t, err, "uploads on with nowhere to transcribe must fail loudly at start-up, not at the first upload")
|
assert.Error(t, err, "uploads on with nowhere to transcribe must fail loudly at start-up, not at the first upload")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestBuildUploads_RemovesAudioLeftBehindByACrash(t *testing.T) {
|
||||||
|
cfg := uploadCfg(t, true)
|
||||||
|
require.NoError(t, os.MkdirAll(cfg.UploadTmpDir, 0o700))
|
||||||
|
leftovers := []string{"upload-123", "wav-456"}
|
||||||
|
for _, n := range leftovers {
|
||||||
|
require.NoError(t, os.WriteFile(filepath.Join(cfg.UploadTmpDir, n), []byte("audio"), 0o600))
|
||||||
|
}
|
||||||
|
unrelated := filepath.Join(cfg.UploadTmpDir, "someone-elses-file")
|
||||||
|
require.NoError(t, os.WriteFile(unrelated, []byte("keep"), 0o600))
|
||||||
|
|
||||||
|
_, _, err := buildUploads(context.Background(), cfg, &fakeUploadsStore{}, quietLog())
|
||||||
|
|
||||||
|
require.NoError(t, err)
|
||||||
|
for _, n := range leftovers {
|
||||||
|
_, err := os.Stat(filepath.Join(cfg.UploadTmpDir, n))
|
||||||
|
assert.True(t, os.IsNotExist(err), "%s: audio is never retained, so a spooled file from a crashed run must not survive start-up", n)
|
||||||
|
}
|
||||||
|
_, err = os.Stat(unrelated)
|
||||||
|
assert.NoError(t, err, "only our own spool files are removed")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user