An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
// SiYuan - https://github.com/siyuan-note/siyuan
// Copyright (c) 2020-present, b3log.org
// SPDX-License-Identifier: AGPL-3.0-or-later
package model
import "testing"
func TestImageAssetMetadataHits(t *testing.T) {
markdowns := []string{
` `,
``,
``,
``,
}
for _, tc := range []struct {
keyword, path string
}{
{"TRAINING", "assets/first.png"},
{"second hint", "assets/second.png"},
{"alternate", "assets/first.png"},
{"100%", "assets/a b.png"},
{"space & percent", "assets/a b.png"},
} {
hits := imageAssetMetadataHits(markdowns, []string{tc.keyword})
for path, count := range hits {
if (count > 0) != (path == tc.path) {
t.Fatalf("metadata search %q: %s=%d, expected %s", tc.keyword, path, count, tc.path)
}
}
if hits[tc.path] == 0 {
t.Fatalf("metadata search %q did not match %s", tc.keyword, tc.path)
}
}
}