MCPcopy
hub / github.com/expr-lang/expr / TestCoreDNS

Function TestCoreDNS

test/coredns/coredns_test.go:13–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestCoreDNS(t *testing.T) {
14 env := coredns.DefaultEnv(context.Background(), &coredns.Request{})
15
16 tests := []struct {
17 input string
18 }{
19 {`metadata('geoip/city/name') == 'Exampleshire'`},
20 {`(type() == 'A' && name() == 'example.com') || client_ip() == '1.2.3.4'`},
21 {`name() matches '^abc\\..*\\.example\\.com\\.$'`},
22 {`type() in ['A', 'AAAA']`},
23 {`incidr(client_ip(), '192.168.0.0/16')`},
24 {`incidr(client_ip(), '127.0.0.0/24')`},
25 }
26
27 for _, test := range tests {
28 t.Run(test.input, func(t *testing.T) {
29 _, err := expr.Compile(test.input, expr.Env(env), expr.DisableBuiltin("type"))
30 assert.NoError(t, err)
31 })
32 }
33}

Callers

nothing calls this directly

Calls 6

DefaultEnvFunction · 0.92
CompileFunction · 0.92
EnvStruct · 0.92
DisableBuiltinFunction · 0.92
NoErrorFunction · 0.92
RunMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…