- API 서비스 workerclient Hello 함수에 context.Err() 선행 검증 추가 - Hello 요청을 goroutine으로 비동기 처리하고 select로 ctx.Done() 감지 - 이미 초과된 deadline인 경우 즉시 에러 반환 - worker 서비스 config에서 strconv import를 config.go로 이동 - worker socket session handler 및 registerHandlers 테스트 추가 - parser_map 테스트 파일 신규 추가
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
)
|
|
|
|
func TestConfigLoad(t *testing.T) {
|
|
os.Setenv("ALT_WORKER_HOST", "127.0.0.9")
|
|
os.Setenv("ALT_WORKER_PORT", "9999")
|
|
os.Setenv("ALT_WORKER_SOCKET_PATH", "/ws-test")
|
|
defer func() {
|
|
os.Unsetenv("ALT_WORKER_HOST")
|
|
os.Unsetenv("ALT_WORKER_PORT")
|
|
os.Unsetenv("ALT_WORKER_SOCKET_PATH")
|
|
}()
|
|
|
|
cfg := Load()
|
|
|
|
if cfg.Host != "127.0.0.9" {
|
|
t.Errorf("expected Host to be 127.0.0.9, got %q", cfg.Host)
|
|
}
|
|
if cfg.Port != 9999 {
|
|
t.Errorf("expected Port to be 9999, got %d", cfg.Port)
|
|
}
|
|
if cfg.SocketPath != "/ws-test" {
|
|
t.Errorf("expected SocketPath to be /ws-test, got %q", cfg.SocketPath)
|
|
}
|
|
}
|
|
|
|
func TestConfigDefault(t *testing.T) {
|
|
os.Unsetenv("ALT_WORKER_HOST")
|
|
os.Unsetenv("ALT_WORKER_PORT")
|
|
os.Unsetenv("ALT_WORKER_SOCKET_PATH")
|
|
|
|
cfg := Load()
|
|
|
|
if cfg.Host != "127.0.0.1" {
|
|
t.Errorf("expected default Host to be 127.0.0.1, got %q", cfg.Host)
|
|
}
|
|
if cfg.Port != 8081 {
|
|
t.Errorf("expected default Port to be 8081, got %d", cfg.Port)
|
|
}
|
|
if cfg.SocketPath != "/socket" {
|
|
t.Errorf("expected default SocketPath to be /socket, got %q", cfg.SocketPath)
|
|
}
|
|
}
|