43 lines
1.6 KiB
Go
43 lines
1.6 KiB
Go
|
|
package cli
|
||
|
|
|
||
|
|
import (
|
||
|
|
"os"
|
||
|
|
"path/filepath"
|
||
|
|
"strings"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestMaintainedApplicationExamplesUseNativeLoading(t *testing.T) {
|
||
|
|
root, err := filepath.Abs(filepath.Join("..", "..", ".."))
|
||
|
|
if err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
t.Chdir(root)
|
||
|
|
entries, err := os.ReadDir("examples")
|
||
|
|
if err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
for _, entry := range entries {
|
||
|
|
if entry.IsDir() || !strings.HasPrefix(entry.Name(), "config") || !strings.HasSuffix(entry.Name(), ".yml") {
|
||
|
|
continue
|
||
|
|
}
|
||
|
|
path := filepath.Join("examples", entry.Name())
|
||
|
|
for _, scope := range []string{"app", "promptkit"} {
|
||
|
|
outcome, _, diagnostics := executeNative(t, "config", "validate", "--config="+path, "--scope="+scope)
|
||
|
|
if outcome.Status != 0 {
|
||
|
|
t.Fatalf("%s/%s: %+v %q", path, scope, outcome, diagnostics)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
for _, test := range []struct{ config, overlay string }{{"examples/config.yml", ""}, {"examples/config.composed.yml", "local"}, {"examples/config.collections.yml", "collection"}, {"examples/config.inheritance.yml", ""}} {
|
||
|
|
args := []string{"promptkit", "show", "prepared", "generic.markdown_summary", "--config=" + test.config, "--profile=local-gpu", "--input-file=transcript=examples/fixtures/transcript.md", "--input-file=glossary=examples/fixtures/glossary.yml", "--format=json"}
|
||
|
|
if test.overlay != "" {
|
||
|
|
args = append(args, "--overlay="+test.overlay)
|
||
|
|
}
|
||
|
|
outcome, output, diagnostics := executeNative(t, args...)
|
||
|
|
if outcome.Status != 0 || !strings.Contains(output, "generic.markdown_summary") || !strings.Contains(output, "Session Transcript") {
|
||
|
|
t.Fatalf("%+v: %+v %q %q", test, outcome, output, diagnostics)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|