1 parent
476c85ac56
commit
e603295df3
7 files changed
+118
-5
No files matched your search
@@ -57,6 +57,10 @@ func configErrorDetails(err error) (string, int, string, map[string]string) {
|
||||
code = "CONFIG_ROLLBACK_IN_PROGRESS"
|
||||
status = http.StatusConflict
|
||||
message = "配置回滚正在执行,请稍后查看结果"
|
||||
case errors.Is(err, config.ErrRuntimeSnapshotUnavailable):
|
||||
code = "CONFIG_RUNTIME_SNAPSHOT_UNAVAILABLE"
|
||||
status = http.StatusServiceUnavailable
|
||||
message = "配置已保存,但运行时配置尚未切换,请重试应用"
|
||||
case errors.Is(err, config.ErrGenerationConflict):
|
||||
code = "CONFIG_GENERATION_CONFLICT"
|
||||
status = http.StatusConflict
|
||||
|
||||
@@ -169,6 +169,22 @@ func TestConfigErrorDetailsMapsDatabaseMigrationFailures(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigErrorDetailsMapsRuntimeSnapshotUnavailable(t *testing.T) {
|
||||
code, status, message, fields := configErrorDetails(config.ErrRuntimeSnapshotUnavailable)
|
||||
if code != "CONFIG_RUNTIME_SNAPSHOT_UNAVAILABLE" {
|
||||
t.Fatalf("error code = %q", code)
|
||||
}
|
||||
if status != http.StatusServiceUnavailable {
|
||||
t.Fatalf("status = %d", status)
|
||||
}
|
||||
if message != "配置已保存,但运行时配置尚未切换,请重试应用" {
|
||||
t.Fatalf("message = %q", message)
|
||||
}
|
||||
if fields != nil {
|
||||
t.Fatalf("fields = %+v, want nil", fields)
|
||||
}
|
||||
}
|
||||
|
||||
func TestConfigErrorDetailsMapsRollbackInProgress(t *testing.T) {
|
||||
code, status, message, _ := configErrorDetails(config.ErrRollbackInProgress)
|
||||
if code != "CONFIG_ROLLBACK_IN_PROGRESS" || status != http.StatusConflict {
|
||||
|
||||
Reference in new issue
Block a user