mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-07-12 09:05:24 +00:00
60 lines
1.1 KiB
Go
60 lines
1.1 KiB
Go
package http
|
|
|
|
import "testing"
|
|
|
|
func TestExtractIdentityName(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
content string
|
|
want string
|
|
}{
|
|
{
|
|
name: "extracts inline markdown name",
|
|
content: `# IDENTITY.md - Who Am I?
|
|
|
|
- **Name:** GoClaw
|
|
- **Creature:** AI assistant`,
|
|
want: "GoClaw",
|
|
},
|
|
{
|
|
name: "ignores next bullet when name is blank",
|
|
content: `# IDENTITY.md - Who Am I?
|
|
|
|
- **Name:**
|
|
- **Creature:** AI assistant`,
|
|
want: "",
|
|
},
|
|
{
|
|
name: "rejects inline spillover from another field",
|
|
content: `# IDENTITY.md - Who Am I?
|
|
|
|
- **Name:** - **Creature:** AI assistant
|
|
- **Purpose:** Help users`,
|
|
want: "",
|
|
},
|
|
{
|
|
name: "strips simple markdown wrappers from name",
|
|
content: `# IDENTITY.md - Who Am I?
|
|
|
|
- **Name:** **GoClaw**
|
|
- **Creature:** AI assistant`,
|
|
want: "GoClaw",
|
|
},
|
|
{
|
|
name: "supports plain name format",
|
|
content: `# Identity
|
|
Name: GoClaw
|
|
Emoji: 🤖`,
|
|
want: "GoClaw",
|
|
},
|
|
}
|
|
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
if got := extractIdentityName(tt.content); got != tt.want {
|
|
t.Fatalf("extractIdentityName() = %q, want %q", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|