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

Function TestRejectsGlobalMatcher

caddyconfig/caddyfile/parse_test.go:865–886  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

863}
864
865func TestRejectsGlobalMatcher(t *testing.T) {
866 p := testParser(`
867 @rejected path /foo
868
869 (common) {
870 gzip foo
871 errors stderr
872 }
873
874 http://example.com {
875 import common
876 }
877 `)
878 _, err := p.parseAll()
879 if err == nil {
880 t.Fatal("Expected an error, but got nil")
881 }
882 expected := "request matchers may not be defined globally, they must be in a site block; found @rejected, at Testfile:2"
883 if err.Error() != expected {
884 t.Errorf("Expected error to be '%s' but got '%v'", expected, err)
885 }
886}
887
888func TestRejectAnonymousImportBlock(t *testing.T) {
889 p := testParser(`

Callers

nothing calls this directly

Calls 3

testParserFunction · 0.85
parseAllMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected