Files
knowledge-governance/internal/workflows/artifactfetch/handler_test.go
姚章浩 b3c9331966 feat(ingest): 源与目录文件名过滤及钉钉文档导出
- filename_filter_rules table (000035) with source-root and per-directory rows
- additive inheritance: source default + every ancestor directory contributes
- filename_is_filtered() SQL predicate applied to catalog browsing, subtree
  counts, change-set diffing, routing fan-out and artifact fetch manifests
- fetch_state 'filtered' (CHECK extended); reconcile cancels/restores fetch
  jobs, retires planned publications and blocks items when rules change
- GET/PUT/DELETE /api/v1/filename-filters (Idempotency-Key, normalized
  extensions) + Settings and Catalog filter editors
- failJobSQL no longer swallows the claimed row when the failure projection
  upserts (fixes spurious 'lease lost' retries)
- DingTalk live fetch: adoc/axls now use the export-job pipeline (HTTP 403
  from file/download fixed), header-signature downloads supported
2026-09-30 10:54:07 +08:00

43 lines
1.2 KiB
Go

package artifactfetch
import (
"context"
"encoding/json"
"testing"
"time"
"knowledge-governance/internal/jobs"
)
type filteredStore struct{}
func (filteredStore) LoadArtifactFetchManifest(context.Context, string, string) (Manifest, error) {
return Manifest{}, ErrManifestFiltered
}
func (filteredStore) MarkArtifactFetched(context.Context, string, string, int64, string, string, bool, time.Time) error {
return nil
}
func (filteredStore) MarkArtifactFetchMissing(context.Context, string, string, time.Time) error {
return nil
}
func (filteredStore) MarkArtifactFetchFailed(context.Context, string, string, string, time.Time) error {
return nil
}
type panicRunner struct{}
func (panicRunner) Run(context.Context, Manifest) (Result, error) {
panic("filtered artifacts must not start a source fetch")
}
func TestHandlerCompletesFilteredArtifactWithoutRunningFetcher(t *testing.T) {
handler, err := NewHandler(Config{Store: filteredStore{}, Runner: panicRunner{}})
if err != nil {
t.Fatal(err)
}
payload, _ := json.Marshal(Request{ConnectionID: "conn-1", NodeID: "node-1", VersionID: "version-1"})
if err := handler.Handle(context.Background(), jobs.Job{Payload: payload}); err != nil {
t.Fatalf("Handle() error = %v", err)
}
}