mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-08-13 22:37:28 +00:00
fix(files): preserve existing file on failed quota upload (#68)
Co-authored-by: rissrice2105-agent <289161642+rissrice2105-agent@users.noreply.github.com>
This commit is contained in:
parent
51273e9a4a
commit
3e28a57b5d
2 changed files with 59 additions and 2 deletions
|
|
@ -169,6 +169,27 @@ func TestQuotaEnforced(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestWebSaveOverQuotaPreservesExistingFile(t *testing.T) {
|
||||
svc, _, u := newTestService(t)
|
||||
sess, _ := svc.newSession(u)
|
||||
sess.quota = 5
|
||||
|
||||
if _, err := sess.webSave("/me/note.txt", strings.NewReader("ok")); err != nil {
|
||||
t.Fatalf("initial save failed: %v", err)
|
||||
}
|
||||
if _, err := sess.webSave("/me/note.txt", strings.NewReader("too-large")); err != errQuota {
|
||||
t.Fatalf("over-quota replace: got %v, want errQuota", err)
|
||||
}
|
||||
|
||||
got, err := os.ReadFile(filepath.Join(svc.privRoot(u.Name), "note.txt"))
|
||||
if err != nil {
|
||||
t.Fatalf("existing file should remain after failed replace: %v", err)
|
||||
}
|
||||
if string(got) != "ok" {
|
||||
t.Fatalf("existing file changed after failed replace: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUsage(t *testing.T) {
|
||||
svc, _, u := newTestService(t)
|
||||
if err := svc.ensureWorkspace(u.Name); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue