MCPcopy Index your code
hub / github.com/expr-lang/expr / TestWithContext_env_struct

Function TestWithContext_env_struct

patcher/with_context_test.go:73–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestWithContext_env_struct(t *testing.T) {
74 withContext := patcher.WithContext{Name: "ctx"}
75
76 program, err := expr.Compile(`Fn(40)`, expr.Env(testEnvContext{}), expr.Patch(withContext))
77 require.NoError(t, err)
78
79 ctx := context.WithValue(context.Background(), "value", 2)
80 env := testEnvContext{
81 Context: ctx,
82 }
83
84 output, err := expr.Run(program, env)
85 require.NoError(t, err)
86 require.Equal(t, 42, output)
87}
88
89type TestFoo struct {
90 contextValue int

Callers

nothing calls this directly

Calls 6

CompileFunction · 0.92
EnvStruct · 0.92
PatchFunction · 0.92
NoErrorFunction · 0.92
RunFunction · 0.92
EqualFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…