diff --git a/parser/parser_test.go b/parser/parser_test.go index 8de5c4b..d04c0e9 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -1,6 +1,7 @@ package parser import ( + "os" "testing" "github.com/tufanbarisyildirim/gonginx/config" @@ -361,6 +362,18 @@ func TestParser_Issue32(t *testing.T) { assert.NilError(t, err, "no error expected here") } +func TestParser_Issue50(t *testing.T) { + t.Parallel() + p, err := NewParser("../testdata/issues/50.conf") + assert.NilError(t, err, "no error expected here") + data, err := os.ReadFile("../testdata/issues/50.conf") + assert.NilError(t, err, "no error expected here") + c, err := p.Parse() + assert.NilError(t, err, "no error expected here") + content := dumper.DumpConfig(c, dumper.IndentedStyle) + assert.Equal(t, content, string(data)) +} + func TestParser_SkipBlock(t *testing.T) { t.Parallel() conf := `user root; diff --git a/testdata/issues/50.conf b/testdata/issues/50.conf new file mode 100644 index 0000000..57adf70 --- /dev/null +++ b/testdata/issues/50.conf @@ -0,0 +1,29 @@ +worker_processes 1;#global inlinecomment +events { + worker_connections 1024;#event inlinecomment +} +http { + include mime.types;#http inlinecomment + default_type application/octet-stream; + sendfile on; + keepalive_timeout 65; + server { + listen 80;#server inlinecomment + server_name localhost; + location / { + root /usr/share/nginx/html;#location inlinecomment + index index.html index.htm; + } + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } + } + server { + listen 8000; + location / { + root html; + index index.html index.htm; + } + } +} \ No newline at end of file