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) {
|
func CreateProvider(cfg *config.Config) (LLMProvider, string, error) {
|
||||||
model := cfg.Agents.Defaults.GetModelName()
|
model := cfg.Agents.Defaults.GetModelName()
|
||||||
|
|
||||||
// Ensure model_list is populated (should be done by LoadConfig, but handle edge cases)
|
// Ensure model_list is populated from providers config if needed
|
||||||
if len(cfg.ModelList) == 0 && cfg.HasProvidersConfig() {
|
// This handles two cases:
|
||||||
cfg.ModelList = config.ConvertProvidersToModelList(cfg)
|
// 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
|
// Must have model_list at this point
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
package skills
|
package skills
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
@ -368,28 +366,10 @@ No frontmatter here`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testcases {
|
for _, tt := range tests {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
// Extract frontmatter
|
result := loader.extractFrontmatter(tt.content)
|
||||||
frontmatter := sl.extractFrontmatter(tc.content)
|
assert.Equal(t, tt.expected, result)
|
||||||
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,
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -530,10 +510,24 @@ func TestStripFrontmatter(t *testing.T) {
|
||||||
content string
|
content string
|
||||||
expectedContent string
|
expectedContent string
|
||||||
lineEndingType 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) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
result := loader.extractFrontmatter(tt.content)
|
result := sl.stripFrontmatter(tt.content)
|
||||||
assert.Equal(t, tt.expected, result)
|
assert.Equal(t, tt.expectedContent, result)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue