管理端可配类型/体积;上传改流式避免整文件进内存;发帖先选再传并拦截未上传提交;提高 Next proxy 体积上限。 Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
762 B
Go
37 lines
762 B
Go
package service
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestAttachmentExtAllowedLogic(t *testing.T) {
|
|
// Normalize + default list contains msi/html
|
|
found := false
|
|
for _, e := range DefaultAttachmentExts {
|
|
if e == "msi" {
|
|
found = true
|
|
break
|
|
}
|
|
}
|
|
if !found {
|
|
t.Fatal("default list should include msi")
|
|
}
|
|
}
|
|
|
|
func TestMimeForAttachmentExt(t *testing.T) {
|
|
if MimeForAttachmentExt(".pdf") == "application/octet-stream" {
|
|
t.Fatal("pdf should have real mime")
|
|
}
|
|
if MimeForAttachmentExt(".html") != "application/octet-stream" {
|
|
t.Fatal("html should be octet-stream")
|
|
}
|
|
}
|
|
|
|
func TestFileMaxBytesDefault(t *testing.T) {
|
|
if FileMaxBytes != 20<<20 {
|
|
t.Fatalf("default FileMaxBytes=%d", FileMaxBytes)
|
|
}
|
|
_ = fmt.Sprintf("%d", DefaultAttachmentMaxMB)
|
|
}
|