MCPcopy
hub / github.com/caddyserver/caddy / TestMatchExpressionProvision

Function TestMatchExpressionProvision

modules/caddyhttp/celmatcher_test.go:545–575  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

543}
544
545func TestMatchExpressionProvision(t *testing.T) {
546 tests := []struct {
547 name string
548 expression *MatchExpression
549 wantErr bool
550 }{
551 {
552 name: "boolean matches succeed",
553 expression: &MatchExpression{
554 Expr: "{http.request.uri.query} != ''",
555 },
556 wantErr: false,
557 },
558 {
559 name: "reject expressions with non-boolean results",
560 expression: &MatchExpression{
561 Expr: "{http.request.uri.query}",
562 },
563 wantErr: true,
564 },
565 }
566 for _, tt := range tests {
567 t.Run(tt.name, func(t *testing.T) {
568 ctx, cancel := caddy.NewContext(caddy.Context{Context: context.Background()})
569 defer cancel()
570 if err := tt.expression.Provision(ctx); (err != nil) != tt.wantErr {
571 t.Errorf("MatchExpression.Provision() error = %v, wantErr %v", err, tt.wantErr)
572 }
573 })
574 }
575}

Callers

nothing calls this directly

Calls 1

ProvisionMethod · 0.65

Tested by

no test coverage detected