Skip to content

Commit 852abe3

Browse files
authored
Add more unix socket unit tests (#1156)
1 parent 1500b62 commit 852abe3

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

internal/datasource/config/nginx_config_parser_test.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,31 @@ var (
260260
api write=on;
261261
}
262262
}
263+
`
264+
265+
testConf22 = ` server {
266+
listen unix:/var/lib/nginx/nginx-plus-api.sock;
267+
access_log off;
268+
269+
# $config_version_mismatch is defined in /etc/nginx/config-version.conf
270+
location /configVersionCheck {
271+
if ($config_version_mismatch) {
272+
return 503;
273+
}
274+
return 200;
275+
}
276+
277+
location /api {
278+
api write=on;
279+
}
280+
}
281+
282+
server {
283+
listen unix:/var/lib/nginx/nginx-418-server.sock;
284+
access_log off;
285+
286+
return 418;
287+
}
263288
`
264289
)
265290

@@ -965,9 +990,20 @@ func TestNginxConfigParser_urlsForLocationDirective(t *testing.T) {
965990
Location: "/api",
966991
},
967992
},
968-
name: "Test 21: listen unix:/var/run/nginx/nginx-plus-api.sock- Plus Unix Socket",
993+
name: "Test 21: listen unix:/var/run/nginx/nginx-plus-api.sock - Plus Unix Socket",
969994
conf: testConf21,
970995
},
996+
{
997+
plus: []*model.APIDetails{
998+
{
999+
URL: "http://nginx-plus-api/api",
1000+
Listen: "unix:/var/lib/nginx/nginx-plus-api.sock",
1001+
Location: "/api",
1002+
},
1003+
},
1004+
name: "Test 22: Multiple Plus Unix Sockets",
1005+
conf: testConf22,
1006+
},
9711007
} {
9721008
ctx := context.Background()
9731009
f, err := os.CreateTemp(tmpDir, "conf")

0 commit comments

Comments
 (0)