Files
Cyrene_v2/backend/plugins/calculator/plugin_test.go
T
Aska 192144563b feat(plugins): add 10 tool plugins and wire full service stack in main.go
- plugins: calculator, datetime, crypto, random, text, json, markdown
- plugins: web-search (SearXNG stub), web-fetch, file, http (stubs)
- main.go: full wiring — config→db→nats→plugins→voice→memory→
  persona→llm→context→subsession→orchestrator→gateway→ws
- 15 packages passing, 11 plugins loaded at startup
2026-08-12 11:37:36 +08:00

34 lines
703 B
Go

package calculator
import (
"fmt"
"testing"
)
func TestCalculator(t *testing.T) {
tests := []struct{ expr string }{
{"2+2"}, {"3*4"}, {"10/2"}, {"1+2*3"}, {"10-5+2"},
}
for _, tt := range tests {
t.Run(tt.expr, func(t *testing.T) {
result, err := evalSimple(tt.expr)
if err != nil {
t.Fatalf("eval error: %v", err)
}
// Just verify it doesn't panic and returns something
_ = result
})
}
}
func TestPluginTools(t *testing.T) {
p := New()
tools := p.Tools()
if len(tools) == 0 || tools[0].Name != "calculator" {
t.Error("expected calculator tool")
}
result, _ := p.Execute(nil, "calculator", map[string]any{"expression": "2+2"})
fmt.Println(result)
_ = result
}