mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-12-03 23:54:36 +08:00
- Route pre-configuration startup logs to stderr and return exit status 1 from a deferred-safe run helper when config loading, store bootstrap, or TUI execution fails. - Propagate synchronous proxy service build and runtime errors from StartServiceWithPluginHost to stderr and exit status 1 while preserving exit status 0 on graceful context cancellation. - Add subprocess and unit regression tests covering missing config, malformed YAML, TUI failures, occupied ports, and interrupt shutdown. Closes: #7459 Co-authored-by: Dylan <1990016@gmail.com> Co-authored-by: lzt404 <2596933790@qq.com>
19 lines
597 B
Go
19 lines
597 B
Go
package cmd
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestStartServiceReturnsBuildError(t *testing.T) {
|
|
if errStart := StartService(nil, "", ""); errStart == nil || !strings.Contains(errStart.Error(), "configuration is required") {
|
|
t.Fatalf("expected missing configuration error, got %v", errStart)
|
|
}
|
|
}
|
|
|
|
func TestStartServiceWithPluginHostReturnsBuildError(t *testing.T) {
|
|
if errStart := StartServiceWithPluginHost(nil, "", "", nil); errStart == nil || !strings.Contains(errStart.Error(), "configuration is required") {
|
|
t.Fatalf("expected missing configuration error, got %v", errStart)
|
|
}
|
|
}
|