refactor: use nginx -s reload instead of systemd
- doc: add comment
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
// serverConfiguration 含受管理 upstream 块、8080 被注释、8081 活动的示例配置,供各测试共享。
|
||||
const serverConfiguration = `http {
|
||||
upstream yms-server {
|
||||
# yms-update managed upstream begin
|
||||
@@ -16,6 +17,8 @@ const serverConfiguration = `http {
|
||||
}
|
||||
`
|
||||
|
||||
// TestActiveBackendPortReadsExactManagedBlock 验证 ActiveBackendPort 能从示例配置中
|
||||
// 精确读取到活动端口 8081。
|
||||
func TestActiveBackendPortReadsExactManagedBlock(t *testing.T) {
|
||||
port, err := ActiveBackendPort([]byte(serverConfiguration))
|
||||
if err != nil || port != 8081 {
|
||||
@@ -23,6 +26,8 @@ func TestActiveBackendPortReadsExactManagedBlock(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRenderBackendPortPreservesConfigurationAndSwitchesOneServer 验证 RenderBackendPort
|
||||
// 只切换一条服务器行,其余配置保持不变,且渲染结果的活动端口正确。
|
||||
func TestRenderBackendPortPreservesConfigurationAndSwitchesOneServer(t *testing.T) {
|
||||
rendered, err := RenderBackendPort([]byte(serverConfiguration), 8080)
|
||||
if err != nil {
|
||||
@@ -38,6 +43,8 @@ func TestRenderBackendPortPreservesConfigurationAndSwitchesOneServer(t *testing.
|
||||
}
|
||||
}
|
||||
|
||||
// TestManagedBlockRejectsAmbiguousOrAlteredInput 验证受管理块在端口双活、端口缺失、
|
||||
// 选项被篡改或出现多余行等情况下都会被拒绝。
|
||||
func TestManagedBlockRejectsAmbiguousOrAlteredInput(t *testing.T) {
|
||||
tests := map[string]string{
|
||||
"both active": strings.Replace(serverConfiguration, "# server 10.11.1.117:8080", "server 10.11.1.117:8080", 1),
|
||||
|
||||
Reference in New Issue
Block a user