feat: add banner printing functionality to server startup

This commit is contained in:
mlogclub
2026-05-24 20:13:18 +08:00
parent 8bbd6c9414
commit c9ad978da6
3 changed files with 86 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package bootstrap
import (
"strings"
"testing"
"cs-agent/internal/pkg/config"
)
func TestRenderBanner(t *testing.T) {
got := renderBanner(config.Config{
Server: config.ServerConfig{Port: 8083},
DB: config.DBConfig{Type: "sqlite"},
})
expected := []string{
":: Shell AI ::",
"Port : 8083",
"DB : sqlite",
"Address : http://127.0.0.1:8083",
}
for _, item := range expected {
if !strings.Contains(got, item) {
t.Fatalf("renderBanner() missing %q in:\n%s", item, got)
}
}
}
func TestRenderBannerDefaults(t *testing.T) {
got := renderBanner(config.Config{})
expected := []string{
"Port : 8080",
"DB : unknown",
"Address : http://127.0.0.1:8080",
}
for _, item := range expected {
if !strings.Contains(got, item) {
t.Fatalf("renderBanner() missing %q in:\n%s", item, got)
}
}
}