feat(tls): add optional nginx setup and gateway preview

This commit is contained in:
opsx committed 2026-10-21 11:33:44 +08:00
1 parent 9f743e19ad
commit d2f1f5040e
15 files changed
+753 -16

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
package nginxsetup
import (
"strings"
"testing"
)
func TestReleaseSelectsOnlySupportedPackageCommands(t *testing.T) {
for _, tc := range []struct{ raw, manager, install string }{
{"NAME=Ubuntu\nID=ubuntu\nVERSION_ID=24.04\n", "apt-get", "apt-get install -y nginx certbot"},
{"NAME=\"TencentOS Server\"\nVERSION=\"4\"\nID=tencentos\nVERSION_ID=\"4\"\n", "dnf", "dnf install -y nginx certbot"},
{"ID=tencentos\nVERSION_ID=3\n", "", ""},
{"ID=debian\nVERSION_ID=12\n", "", ""},
} {
id, version := ParseOSRelease(tc.raw)
pm, commands := Plan(id, version)
if pm != tc.manager {
t.Errorf("%s: package manager %q", id, pm)
}
if tc.install != "" {
got := strings.Join(commands[len(commands)-1], " ")
if got != tc.install {
t.Errorf("%s: install command %q", id, got)
}
} else if len(commands) != 0 {
t.Errorf("%s should be unsupported", id)
}
}
}
func TestOnlyOneInitializationAtATime(t *testing.T) {
if !Begin() {
t.Fatal("first initialization rejected")
}
defer End()
if Begin() {
t.Fatal("concurrent initialization accepted")
}
}