UploadToFolderReplacing deletes same-stem files before upload (--replace, default true). OO may still display title+fileExst as double extension. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
911 B
Go
36 lines
911 B
Go
package onlyoffice
|
|
|
|
import "testing"
|
|
|
|
func TestNormalizeUploadStem(t *testing.T) {
|
|
tests := []struct {
|
|
title, exst, want string
|
|
}{
|
|
{"OO-HONDA-7-INDEX.docx", ".docx", "OO-HONDA-7-INDEX"},
|
|
{"README.txt", ".txt", "README"},
|
|
{"car-docs-print.docx", ".docx", "car-docs-print"},
|
|
{"plain.", "", "plain"},
|
|
{"foo", ".docx", "foo"},
|
|
}
|
|
for _, tc := range tests {
|
|
if got := NormalizeUploadStem(tc.title, tc.exst); got != tc.want {
|
|
t.Fatalf("NormalizeUploadStem(%q,%q)=%q want %q", tc.title, tc.exst, got, tc.want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestFileEntryStem(t *testing.T) {
|
|
title := "00-INDEX.docx"
|
|
exst := ".docx"
|
|
f := &FileEntry{Title: &title, FileExst: &exst}
|
|
if got := FileEntryStem(f); got != "00-INDEX" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|
|
|
|
func TestUploadStemFromLocal(t *testing.T) {
|
|
if got := UploadStemFromLocal("/tmp/OO-HONDA-7-INDEX.docx"); got != "OO-HONDA-7-INDEX" {
|
|
t.Fatalf("got %q", got)
|
|
}
|
|
}
|