25 lines
764 B
Go
25 lines
764 B
Go
package service
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
func TestImportScriptAnalysisFileRejectsUnsupportedFormat(t *testing.T) {
|
|
service := &Creative{}
|
|
_, err := service.ImportScriptAnalysisFile(uuid.New(), uuid.New(), "script.docx", []byte("content"))
|
|
if err == nil || !strings.Contains(err.Error(), "仅支持TXT和DOC文件") {
|
|
t.Fatalf("expected unsupported format error, got %v", err)
|
|
}
|
|
}
|
|
|
|
func TestImportScriptAnalysisFileRejectsOversizedFile(t *testing.T) {
|
|
service := &Creative{}
|
|
_, err := service.ImportScriptAnalysisFile(uuid.New(), uuid.New(), "script.txt", make([]byte, maxDramaImportBytes+1))
|
|
if err == nil || !strings.Contains(err.Error(), "不能超过3MB") {
|
|
t.Fatalf("expected file size error, got %v", err)
|
|
}
|
|
}
|