mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-09-03 18:16:45 +00:00
- Add migration 000048: vault_documents.path_basename + vault_links.metadata (PG) - Update SQLite schema.sql: add path_basename, metadata columns + v15→v16 markers - Add schema.go backfill: loop-patch v15→v16 + basename extraction for existing docs - Update vault_documents store: SELECT/INSERT with path_basename (PG + SQLite) - Update vault_links store: SELECT/INSERT with metadata (PG + SQLite) - Add vault_source_cleanup: helper to purge orphaned sources + links by source ID - Add basename_helper.go + test: extract filename from path for DB sync - Update version.go: RequiredSchemaVersion → 48, SQLite SchemaVersion → 16 - Update vault_store.go: DeleteLinksBySource + BatchFindByDelegationIDs interface
25 lines
610 B
Go
25 lines
610 B
Go
//go:build sqlite || sqliteonly
|
|
|
|
package sqlitestore
|
|
|
|
import "testing"
|
|
|
|
func TestComputeAttachmentBaseName(t *testing.T) {
|
|
cases := []struct {
|
|
in, want string
|
|
}{
|
|
{"", ""},
|
|
{"file.md", "file.md"},
|
|
{"path/to/file.md", "file.md"},
|
|
{"/abs/path/to/IMAGE.PNG", "image.png"},
|
|
{"path/to/Mixed-Case.TXT", "mixed-case.txt"},
|
|
{"no-slash-just-name.pdf", "no-slash-just-name.pdf"},
|
|
{"deep/nested/folder/doc.docx", "doc.docx"},
|
|
}
|
|
for _, c := range cases {
|
|
if got := ComputeAttachmentBaseName(c.in); got != c.want {
|
|
t.Errorf("ComputeAttachmentBaseName(%q) = %q; want %q", c.in, got, c.want)
|
|
}
|
|
}
|
|
}
|