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

Function TestNavigableSelectExpr_TestOnly

common/ast/navigable_test.go:536–555  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

534}
535
536func TestNavigableSelectExpr_TestOnly(t *testing.T) {
537 checked := mustTypeCheck(t, `has(msg.single_int32)`)
538 expr := ast.NavigateAST(checked)
539 if expr.Kind() != ast.SelectKind {
540 t.Errorf("Kind() got %v, wanted SelectKind", expr.Kind())
541 }
542 sel := expr.AsSelect()
543 if sel.FieldName() != "single_int32" {
544 t.Errorf("FieldName() got %s, wanted single_int32", sel.FieldName())
545 }
546 if sel.Operand().Kind() != ast.IdentKind {
547 t.Fatalf("Operand() kind got %v, wanted ident", sel.Operand().Kind())
548 }
549 if sel.Operand().AsIdent() != "msg" {
550 t.Errorf("Operand() got %v, wanted ident 'msg'", sel.Operand())
551 }
552 if !sel.IsTestOnly() {
553 t.Error("IsTestOnly() got false, wanted true")
554 }
555}
556
557func mustTypeCheck(t testing.TB, expr string, opts ...any) *ast.AST {
558 t.Helper()

Callers

nothing calls this directly

Calls 9

NavigateASTFunction · 0.92
mustTypeCheckFunction · 0.85
KindMethod · 0.65
AsSelectMethod · 0.65
FieldNameMethod · 0.65
OperandMethod · 0.65
AsIdentMethod · 0.65
IsTestOnlyMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected