feat: 优化 Nginx 版本解析逻辑,添加正则表达式匹配,更新测试用例以验证新逻辑

This commit is contained in:
ryan
2026-03-11 10:48:32 +08:00
parent 936b2256ab
commit e895c91ab7
2 changed files with 18 additions and 9 deletions
+12
View File
@@ -244,6 +244,18 @@ func TestDetectVersionFromDockerImage(t *testing.T) {
}
}
func TestParseNginxVersionIgnoresDockerEntrypointPaths(t *testing.T) {
output := strings.Join([]string{
"/docker-entrypoint.sh: /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh: info: can not modify /etc/nginx/conf.d/default.conf (read-only file system?)",
"nginx version: nginx/1.27.4",
}, "\n")
version := parseNginxVersion(output)
if version != "1.27.4" {
t.Fatalf("unexpected version: %s", version)
}
}
func TestManagerApplyWritesSupportFilesAndReplacesPlaceholder(t *testing.T) {
tempDir := t.TempDir()
manager := &Manager{