feat:add test
This commit is contained in:
commit
f814711621
2 changed files with 36 additions and 30 deletions
|
|
@ -18,9 +18,21 @@ import (
|
|||
func CreateProvider(cfg *config.Config) (LLMProvider, string, error) {
|
||||
model := cfg.Agents.Defaults.GetModelName()
|
||||
|
||||
// Ensure model_list is populated (should be done by LoadConfig, but handle edge cases)
|
||||
if len(cfg.ModelList) == 0 && cfg.HasProvidersConfig() {
|
||||
cfg.ModelList = config.ConvertProvidersToModelList(cfg)
|
||||
// Ensure model_list is populated from providers config if needed
|
||||
// This handles two cases:
|
||||
// 1. ModelList is empty - convert all providers
|
||||
// 2. ModelList has some entries but not all providers - merge missing ones
|
||||
if cfg.HasProvidersConfig() {
|
||||
providerModels := config.ConvertProvidersToModelList(cfg)
|
||||
existingModelNames := make(map[string]bool)
|
||||
for _, m := range cfg.ModelList {
|
||||
existingModelNames[m.ModelName] = true
|
||||
}
|
||||
for _, pm := range providerModels {
|
||||
if !existingModelNames[pm.ModelName] {
|
||||
cfg.ModelList = append(cfg.ModelList, pm)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Must have model_list at this point
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package skills
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
|
@ -368,28 +366,10 @@ No frontmatter here`,
|
|||
},
|
||||
}
|
||||
|
||||
for _, tc := range testcases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
// Extract frontmatter
|
||||
frontmatter := sl.extractFrontmatter(tc.content)
|
||||
assert.NotEmpty(t, frontmatter, "Frontmatter should be extracted for %s line endings", tc.lineEndingType)
|
||||
|
||||
// Parse YAML to get name and description (parseSimpleYAML now handles all line ending types)
|
||||
yamlMeta := sl.parseSimpleYAML(frontmatter)
|
||||
assert.Equal(
|
||||
t,
|
||||
tc.expectedName,
|
||||
yamlMeta["name"],
|
||||
"Name should be correctly parsed from frontmatter with %s line endings",
|
||||
tc.lineEndingType,
|
||||
)
|
||||
assert.Equal(
|
||||
t,
|
||||
tc.expectedDesc,
|
||||
yamlMeta["description"],
|
||||
"Description should be correctly parsed from frontmatter with %s line endings",
|
||||
tc.lineEndingType,
|
||||
)
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := loader.extractFrontmatter(tt.content)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -530,10 +510,24 @@ func TestStripFrontmatter(t *testing.T) {
|
|||
content string
|
||||
expectedContent string
|
||||
lineEndingType string
|
||||
for _, tt := range tests {
|
||||
}{
|
||||
{
|
||||
name: "unix",
|
||||
content: `---
|
||||
name: Test
|
||||
description: Desc
|
||||
---
|
||||
|
||||
Content`,
|
||||
expectedContent: "\nContent",
|
||||
lineEndingType: "unix",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range testcases {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
result := loader.extractFrontmatter(tt.content)
|
||||
assert.Equal(t, tt.expected, result)
|
||||
result := sl.stripFrontmatter(tt.content)
|
||||
assert.Equal(t, tt.expectedContent, result)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue