platform: modularize api/gui, add docs-tests-web foundation, and refresh root config

This commit is contained in:
beckline
2026-03-26 22:40:54 +03:00
parent 0e2d7f61ea
commit 6a56d734c2
562 changed files with 70151 additions and 16423 deletions

View File

@@ -0,0 +1,67 @@
package transportcfg
import "testing"
func TestBackendUnitSingBoxUsesInstanceTemplateByDefault(t *testing.T) {
client := Client{
ID: "sg-realnetns",
Kind: KindSingBox,
}
got := BackendUnit(client)
if got != "singbox@sg-realnetns.service" {
t.Fatalf("unexpected singbox unit: %q", got)
}
}
func TestBackendUnitSingBoxTemplateConfigExpandsInstance(t *testing.T) {
client := Client{
ID: "sg-1",
Kind: KindSingBox,
Config: map[string]any{
"unit": "singbox@.service",
},
}
got := BackendUnit(client)
if got != "singbox@sg-1.service" {
t.Fatalf("unexpected template unit: %q", got)
}
}
func TestBackendUnitSingBoxKeepsExplicitNonTemplateUnit(t *testing.T) {
client := Client{
ID: "sg-realnetns",
Kind: KindSingBox,
Config: map[string]any{
"unit": "custom-singbox.service",
},
}
got := BackendUnit(client)
if got != "custom-singbox.service" {
t.Fatalf("unexpected custom unit: %q", got)
}
}
func TestBackendUnitNonSingBoxUnchanged(t *testing.T) {
client := Client{
ID: "dn-1",
Kind: KindDNSTT,
Config: map[string]any{
"unit": "dnstt-custom.service",
},
}
got := BackendUnit(client)
if got != "dnstt-custom.service" {
t.Fatalf("unexpected non-singbox unit: %q", got)
}
}
func TestBackendUnitSingBoxSanitizesInstanceID(t *testing.T) {
client := Client{
ID: " SG Real/NetNS ",
Kind: KindSingBox,
}
got := BackendUnit(client)
if got != "singbox@sg-real-netns.service" {
t.Fatalf("unexpected sanitized singbox unit: %q", got)
}
}