优化结构

This commit is contained in:
Yvan
2026-08-21 10:29:14 +08:00
parent 56980c8087
commit 055f6811ca
340 changed files with 382 additions and 382 deletions
+27
View File
@@ -0,0 +1,27 @@
package main
import (
"testing"
"kra/internal/conf"
)
func TestSwaggerAddress(t *testing.T) {
tests := []struct {
name string
server *conf.Server
admin *conf.AdminBackend
want string
}{
{name: "default", want: "http://127.0.0.1:8000/swagger/index.html"},
{name: "wildcard with prefix", server: &conf.Server{Http: &conf.Server_HTTP{Addr: "0.0.0.0:9000"}}, admin: &conf.AdminBackend{RouterPrefix: "/admin/"}, want: "http://127.0.0.1:9000/admin/swagger/index.html"},
{name: "host", server: &conf.Server{Http: &conf.Server_HTTP{Addr: "example.test:8080"}}, want: "http://example.test:8080/swagger/index.html"},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
if got := swaggerAddress(test.server, test.admin); got != test.want {
t.Fatalf("swaggerAddress() = %q, want %q", got, test.want)
}
})
}
}