Load prompt configuration comparison sides independently
This commit is contained in:
@@ -11,6 +11,8 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"go.maximumdirect.net/ckconfig"
|
||||
"go.maximumdirect.net/ckprompt"
|
||||
commandkit "go.maximumdirect.net/commandkit"
|
||||
pk "go.maximumdirect.net/promptkit"
|
||||
)
|
||||
@@ -80,6 +82,40 @@ func TestExplicitEmptyConfigurationPathFails(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPromptConfigurationComparisonAcquiresEqualSelectionsIndependently(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
main := filepath.Join(dir, "config.yml")
|
||||
if err := os.WriteFile(main, []byte("version: 3\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
resource := filepath.Join(dir, "prompts.yml")
|
||||
writeProfile := func(model string) {
|
||||
t.Helper()
|
||||
if err := os.WriteFile(resource, []byte("profiles: [{id: local, model: "+model+"}]\n"), 0600); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
writeProfile("before")
|
||||
scope := ckprompt.ConfigScope(func(ctx context.Context, selection ckconfig.Selection, input struct{}, state *invocationState) (*pk.Engine, error) {
|
||||
engine, err := loadPromptEngine(ctx, selection, input, state)
|
||||
writeProfile("after")
|
||||
return engine, err
|
||||
})
|
||||
side := ckconfig.ComparisonSide[struct{}]{Selection: ckconfig.Selection{
|
||||
Config: commandkit.Supplied[string]{Value: main, Set: true},
|
||||
}}
|
||||
result, err := scope.Compare(context.Background(), ckconfig.ComparisonRequest[struct{}]{Left: side, Right: side}, &invocationState{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, difference := range result.Value {
|
||||
if strings.Contains(difference.Left.YAML, "before") && strings.Contains(difference.Right.YAML, "after") {
|
||||
return
|
||||
}
|
||||
}
|
||||
t.Fatal("comparison did not capture the model before and after the resource changed")
|
||||
}
|
||||
|
||||
func TestRequestInspectionAndExplicitSmokeUseSameSources(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
file := filepath.Join(dir, "config.yml")
|
||||
|
||||
Reference in New Issue
Block a user