MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / TestNewFunctionScope

Function TestNewFunctionScope

go/engine/scope_test.go:130–154  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128}
129
130func TestNewFunctionScope(t *testing.T) {
131 t.Run("seeds args under SrcFnArg and declared variables", func(t *testing.T) {
132 s, err := NewFunctionScope(
133 []workflowapi.Variable{{Uid: "local", DataType: workflowapi.String, InitialValue: "init"}},
134 map[string]expr.Value{"a": expr.IntVal(5)},
135 )
136 require.NoError(t, err)
137
138 v, err := s.Resolve(workflowapi.Reference{SrcId: SrcFnArg, VarId: "a"})
139 require.NoError(t, err)
140 assert.Equal(t, expr.IntVal(5), v)
141
142 v, err = s.Resolve(workflowapi.Reference{SrcId: SrcDeclared, VarId: "local"})
143 require.NoError(t, err)
144 assert.Equal(t, expr.StringVal("init"), v)
145 })
146
147 t.Run("declared variable seeding error propagates", func(t *testing.T) {
148 _, err := NewFunctionScope(
149 []workflowapi.Variable{{Uid: "bad", DataType: workflowapi.Int, InitialValue: "nope"}},
150 nil,
151 )
152 require.Error(t, err)
153 })
154}
155
156func TestApplyOutput(t *testing.T) {
157 t.Run("inactive binding writes nothing", func(t *testing.T) {

Callers

nothing calls this directly

Calls 4

NewFunctionScopeFunction · 0.85
ResolveMethod · 0.65
RunMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected