MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestCustomDecorator

Function TestCustomDecorator

interpreter/interpreter_test.go:2530–2550  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2528}
2529
2530func TestCustomDecorator(t *testing.T) {
2531 decV1 := func(i Interpretable) (Interpretable, error) {
2532 return i, nil
2533 }
2534 opt := CustomDecorator(decV1)
2535 p := &planner{}
2536 p2, err := opt(p)
2537 if err != nil {
2538 t.Fatalf("CustomDecorator failed: %v", err)
2539 }
2540 if len(p2.decorators) != 1 {
2541 t.Fatalf("CustomDecorator did not add decorator")
2542 }
2543 res, err := p2.decorators[0](NewConstValue(1, types.IntOne))
2544 if err != nil {
2545 t.Fatalf("wrapped decorator failed: %v", err)
2546 }
2547 if res.ID() != 1 {
2548 t.Errorf("wrapped decorator returned node with ID %d, wanted 1", res.ID())
2549 }
2550}
2551
2552func TestCostTrackerActualCost(t *testing.T) {
2553 ct := &CostTracker{cost: 42}

Callers

nothing calls this directly

Calls 3

NewConstValueFunction · 0.85
CustomDecoratorFunction · 0.70
IDMethod · 0.65

Tested by

no test coverage detected