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

Function TestDecodeNonBase64Error

ext/encoders_test.go:278–301  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

276}
277
278func TestDecodeNonBase64Error(t *testing.T) {
279 env := testEncodersCostsEnv(t, 1)
280 pAst, iss := env.Parse("base64.decode('abc-') == b''")
281 if iss.Err() != nil {
282 t.Fatalf("env.Parse() failed: %v", iss.Err())
283 }
284 cAst, iss := env.Check(pAst)
285 if iss.Err() != nil {
286 t.Fatalf("env.Check() failed: %v", iss.Err())
287 }
288 testCheckCost(t, env, cAst, nil, checker.FixedCostEstimate(2))
289 prgOpts := []cel.ProgramOption{}
290 if cAst.IsChecked() {
291 prgOpts = append(prgOpts, cel.CostTracking(nil))
292 }
293 prg, err := env.Program(cAst, prgOpts...)
294 if err != nil {
295 t.Fatalf("env.Program() failed: %v", err)
296 }
297 _, _, err = prg.Eval(cel.NoVars())
298 if err == nil {
299 t.Fatal("expected eval error for non-base64 string decoding, got nil")
300 }
301}
302
303func TestJSONEncodeCostUnbounded(t *testing.T) {
304 env, err := cel.NewEnv(Encoders(EncodersVersion(1)))

Callers

nothing calls this directly

Calls 11

FixedCostEstimateFunction · 0.92
CostTrackingFunction · 0.92
NoVarsFunction · 0.92
testEncodersCostsEnvFunction · 0.85
testCheckCostFunction · 0.85
ErrMethod · 0.80
CheckMethod · 0.80
ProgramMethod · 0.80
ParseMethod · 0.65
EvalMethod · 0.65
IsCheckedMethod · 0.45

Tested by

no test coverage detected