1 parent
d534f0187d
commit
acf03222e9
5 files changed
+140
-21
No files matched your search
@@ -53,6 +53,10 @@ func configErrorDetails(err error) (string, int, string, map[string]string) {
|
||||
code = "CONFIG_MANAGER_UNAVAILABLE"
|
||||
status = http.StatusServiceUnavailable
|
||||
message = "配置服务暂时不可用,请稍后重试"
|
||||
case errors.Is(err, config.ErrRollbackInProgress):
|
||||
code = "CONFIG_ROLLBACK_IN_PROGRESS"
|
||||
status = http.StatusConflict
|
||||
message = "配置回滚正在执行,请稍后查看结果"
|
||||
case errors.Is(err, config.ErrGenerationConflict):
|
||||
code = "CONFIG_GENERATION_CONFLICT"
|
||||
status = http.StatusConflict
|
||||
|
||||
@@ -2,6 +2,7 @@ package controllers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -167,3 +168,13 @@ func TestConfigErrorDetailsMapsDatabaseMigrationFailures(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigErrorDetailsMapsRollbackInProgress(t *testing.T) {
|
||||
code, status, message, _ := configErrorDetails(config.ErrRollbackInProgress)
|
||||
if code != "CONFIG_ROLLBACK_IN_PROGRESS" || status != http.StatusConflict {
|
||||
t.Fatalf("rollback in progress mapping = %q/%d, want conflict", code, status)
|
||||
}
|
||||
if message == "" || strings.Contains(message, "rollback in progress") {
|
||||
t.Fatalf("rollback in progress message is not a Chinese public message: %q", message)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user