35 lines
990 B
Go
35 lines
990 B
Go
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
"git.a-wan.net/alan/pipelines/internal/stage"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestToolsBlockPersistenceAndAdapter(t *testing.T) {
|
|
source := strings.Replace(Template([]string{"one"}, true), "```tools\n```", "```tools\nwebsearch\nwebfetch\n```", 1)
|
|
store, err := Open(filepath.Join(t.TempDir(), "tools.db"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer store.Close()
|
|
ctx := context.Background()
|
|
if _, err := store.Submit(ctx, "web", source); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
items, _ := store.List(ctx)
|
|
d, err := store.Get(ctx, items[0].ID, 1)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
tools, explicit, err := stage.ToolNames(StageDefinition(d.Graph.Stages[0]))
|
|
if err != nil || !explicit || len(tools) != 2 || tools[0] != "websearch" {
|
|
t.Fatal("tool allowlist lost", tools, explicit, err)
|
|
}
|
|
if _, err := Parse(strings.Replace(source, "websearch\nwebfetch", "websearch\nunknown", 1)); err == nil {
|
|
t.Fatal("unknown tool accepted")
|
|
}
|
|
}
|