- 页面 9 个出口统一走 reconciliationMessages:四个内部码不再进入 DOM,未知码回退中文;批次行/阶段码同样翻译。 - 绑定页加载与点击前读 /api/v1/kb-bindings 预检:测试环境未配置当场提示且不发 POST;未启用优先于绑定缺失。 - 运行时读按上游 401/403 与连接失败拆成 runtime_key_forbidden / runtime_unreachable,保留 404 与未配置语义。 - EnvironmentLabel 与前端环境标签改「测试/生产知识库」,不再出现 090。 - 验:make verify 17 项全绿;go test 三包、web 656 用例、typecheck 通过。
This commit is contained in:
@@ -107,3 +107,45 @@ func TestRuntimeProviderDropsSensitiveUpstreamFields(t *testing.T) {
|
||||
t.Fatalf("projection dropped real fields: %#v", progress)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeProviderClassifiesForbiddenAndUnreachable(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
status int
|
||||
want error
|
||||
}{
|
||||
{"forbidden", http.StatusForbidden, ErrRuntimeForbidden},
|
||||
{"unauthorized", http.StatusUnauthorized, ErrRuntimeForbidden},
|
||||
{"upstream-500", http.StatusInternalServerError, ErrRuntimeUnreachable},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
w.WriteHeader(tc.status)
|
||||
}))
|
||||
defer server.Close()
|
||||
provider := NewRuntimeProvider(RuntimeConfig{
|
||||
BaseURL: func(context.Context) string { return server.URL },
|
||||
APIKey: "runtime-key", Timeout: 5 * time.Second,
|
||||
})
|
||||
if _, err := provider.DocumentProgress(context.Background(), "doc-1"); !errors.Is(err, tc.want) {
|
||||
t.Fatalf("status %d err=%v, want %v", tc.status, err, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRuntimeProviderClassifiesClosedListenerAsUnreachable(t *testing.T) {
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
_ = json.NewEncoder(w).Encode(map[string]any{"success": true, "data": map[string]any{}})
|
||||
}))
|
||||
url := server.URL
|
||||
server.Close()
|
||||
provider := NewRuntimeProvider(RuntimeConfig{
|
||||
BaseURL: func(context.Context) string { return url },
|
||||
APIKey: "runtime-key", Timeout: 2 * time.Second,
|
||||
})
|
||||
if _, err := provider.DocumentProgress(context.Background(), "doc-1"); !errors.Is(err, ErrRuntimeUnreachable) {
|
||||
t.Fatalf("closed listener err=%v, want %v", err, ErrRuntimeUnreachable)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user