mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-10 23:36:37 +08:00
fix media workflows and download organization
This commit is contained in:
@@ -112,3 +112,37 @@ func TestRedactSensitiveDownloadURL(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestSiteSearchReturnsErrorWhenAllEnabledSitesFail(t *testing.T) {
|
||||
upstream := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "upstream timeout simulation", http.StatusGatewayTimeout)
|
||||
}))
|
||||
defer upstream.Close()
|
||||
|
||||
db := newServiceTestDB(t, &model.Site{})
|
||||
repos := repository.New(db)
|
||||
svc := NewSiteService(zap.NewNop(), repos, "")
|
||||
site := &model.Site{
|
||||
Name: "馒头",
|
||||
Type: "mteam",
|
||||
URL: upstream.URL,
|
||||
AuthType: "api_key",
|
||||
APIKey: "token-123",
|
||||
Enabled: true,
|
||||
Timeout: 5,
|
||||
}
|
||||
if err := svc.Create(context.Background(), site); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
results, err := svc.Search(context.Background(), "南部档案 2026")
|
||||
if err == nil {
|
||||
t.Fatalf("Search error = nil, want all-sites-failed error; results=%#v", results)
|
||||
}
|
||||
if len(results) != 0 {
|
||||
t.Fatalf("results = %#v, want none on all-sites failure", results)
|
||||
}
|
||||
if !strings.Contains(err.Error(), "all enabled sites failed") || !strings.Contains(err.Error(), "馒头") {
|
||||
t.Fatalf("error = %q, want site failure context", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user