Skip to content

Commit

Permalink
add js_periodic to parse
Browse files Browse the repository at this point in the history
  • Loading branch information
vivki committed Oct 3, 2023
1 parent 656013d commit 3b7e198
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
3 changes: 3 additions & 0 deletions analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,9 @@ var directives = map[string][]uint{
ngxHTTPMainConf | ngxHTTPSrvConf | ngxHTTPLocConf | ngxConfTake1,
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake1,
},
"js_periodic": {
ngxHTTPLocConf | ngxStreamSrvConf | ngxConfAny,
},
"js_preload_object": {
ngxHTTPMainConf | ngxHTTPSrvConf | ngxHTTPLocConf | ngxConfTake13,
ngxStreamMainConf | ngxStreamSrvConf | ngxConfTake13,
Expand Down
19 changes: 18 additions & 1 deletion analyze_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,31 @@ func TestAnalyze_njs(t *testing.T) {
blockCtx{"http", "server", "if"},
true,
},
"js_periodic ok": {
&Directive{
Directive: "js_periodic",
Args: []string{"function"},
Line: 5,
},
blockCtx{"http", "location"},
false,
},
"js_periodic not ok": {
&Directive{
Directive: "js_periodic",
Args: []string{"function"},
Line: 5,
},
blockCtx{"http", "location", "if"},
true,
},
}

for name, tc := range testcases {
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
err := analyze("nginx.conf", tc.stmt, ";", tc.ctx, &ParseOptions{})

if !tc.wantErr && err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 3b7e198

Please sign in to comment.