@@ -1947,7 +1947,7 @@ func TestAnalyze_lua(t *testing.T) {
1947
1947
blockCtx {"http" , "location" , "location if" },
1948
1948
false ,
1949
1949
},
1950
- "content_by_lua_file nor ok" : {
1950
+ "content_by_lua_file not ok" : {
1951
1951
& Directive {
1952
1952
Directive : "content_by_lua_file" ,
1953
1953
Args : []string {"foo/bar.lua" },
@@ -1992,6 +1992,78 @@ func TestAnalyze_lua(t *testing.T) {
1992
1992
blockCtx {"http" },
1993
1993
true ,
1994
1994
},
1995
+ "set_by_lua ok" : {
1996
+ & Directive {
1997
+ Directive : "set_by_lua" ,
1998
+ Args : []string {"$res" , "' return 32 + math.cos(32) '" },
1999
+ Line : 5 ,
2000
+ },
2001
+ blockCtx {"server" },
2002
+ false ,
2003
+ },
2004
+ "set_by_lua not ok" : {
2005
+ & Directive {
2006
+ Directive : "set_by_lua" ,
2007
+ Args : []string {"' return 32 + math.cos(32) '" },
2008
+ Line : 5 ,
2009
+ },
2010
+ blockCtx {"http" },
2011
+ true ,
2012
+ },
2013
+ "set_by_lua_block ok" : {
2014
+ & Directive {
2015
+ Directive : "set_by_lua_block" ,
2016
+ Args : []string {"$res" , "{ return tonumber(ngx.var.foo) + 1 }" },
2017
+ Line : 5 ,
2018
+ },
2019
+ blockCtx {"server" },
2020
+ false ,
2021
+ },
2022
+ "set_by_lua_block not ok" : {
2023
+ & Directive {
2024
+ Directive : "set_by_lua_block" ,
2025
+ Args : []string {"{ return tonumber(ngx.var.foo) + 1 }" },
2026
+ Line : 5 ,
2027
+ },
2028
+ blockCtx {"http" },
2029
+ true ,
2030
+ },
2031
+ "content_by_lua ok" : {
2032
+ & Directive {
2033
+ Directive : "content_by_lua" ,
2034
+ Args : []string {"'ngx.say('I need no extra escaping here, for example: \r \n blah')'" },
2035
+ Line : 5 ,
2036
+ },
2037
+ blockCtx {"location" },
2038
+ false ,
2039
+ },
2040
+ "content_by_lua not ok" : {
2041
+ & Directive {
2042
+ Directive : "content_by_lua" ,
2043
+ Args : []string {"'ngx.say('I need no extra escaping here, for example: \r \n blah')'" },
2044
+ Line : 5 ,
2045
+ },
2046
+ blockCtx {"http" },
2047
+ true ,
2048
+ },
2049
+ "content_by_lua_block ok" : {
2050
+ & Directive {
2051
+ Directive : "content_by_lua_block" ,
2052
+ Args : []string {"{ngx.say('I need no extra escaping here, for example: \r \n blah')}" },
2053
+ Line : 5 ,
2054
+ },
2055
+ blockCtx {"location" },
2056
+ false ,
2057
+ },
2058
+ "content_by_lua_block not ok" : {
2059
+ & Directive {
2060
+ Directive : "content_by_lua_block" ,
2061
+ Args : []string {"{ngx.say('I need no extra escaping here, for example: \r \n blah')}" },
2062
+ Line : 5 ,
2063
+ },
2064
+ blockCtx {"http" },
2065
+ true ,
2066
+ },
1995
2067
}
1996
2068
1997
2069
for name , tc := range testcases {
@@ -2000,6 +2072,11 @@ func TestAnalyze_lua(t *testing.T) {
2000
2072
t .Parallel ()
2001
2073
err := analyze ("nginx.conf" , tc .stmt , ";" , tc .ctx , & ParseOptions {
2002
2074
MatchFuncs : []MatchFunc {MatchLua },
2075
+ LexOptions : LexOptions {
2076
+ ExternalLexers : []ExtLexer {
2077
+ & LuaLexer {},
2078
+ },
2079
+ },
2003
2080
})
2004
2081
2005
2082
if ! tc .wantErr && err != nil {
0 commit comments