Files
poiesis/internal/functions/functions_test.go
2026-01-28 20:58:26 -05:00

34 lines
702 B
Go

package functions
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
type TestArgs struct {
Field1 string `json:"field1"`
}
func (t TestArgs) Validate() error {
return nil
}
func TestAsyncFunction(t *testing.T) {
registryMutex.RLock()
defer registryMutex.RUnlock()
RegisterAsyncFunction("testAsync", func(_ context.Context, args TestArgs) (string, error) {
return "result: " + args.Field1, nil
})
fn, ok := functionRegistry["testAsync"]
require.True(t, ok, "testAsync should be registered")
assert.Contains(t, fn.Definition(), "Promise<string>", "definition should include Promise<string>")
}
// TOOD: Test Normal Function