Skip to content

Commit

Permalink
add test for inline comment
Browse files Browse the repository at this point in the history
  • Loading branch information
chenwei committed Sep 7, 2024
1 parent 67297fa commit a880235
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
13 changes: 13 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package parser

import (
"os"
"testing"

"github.com/tufanbarisyildirim/gonginx/config"
Expand Down Expand Up @@ -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;
Expand Down
29 changes: 29 additions & 0 deletions testdata/issues/50.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
}

0 comments on commit a880235

Please sign in to comment.