WeKnora deployment source with the reviewed wiki identity, summary and recovery fixes
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
Anydoc / anydoc parser engine (push) Canceled after 0s
App / Format, vet, test, and build (push) Canceled after 0s
CLI / test (macos-latest / go 1.26) (push) Canceled after 0s
CLI / test (ubuntu-latest / go 1.26) (push) Canceled after 0s
CLI / test (windows-latest / go 1.26) (push) Canceled after 0s
Build and Push Docker Image / build-ui (push) Canceled after 0s
Build and Push Docker Image / build-docreader (push) Canceled after 0s
Build and Push Docker Image / build-sandbox (push) Canceled after 0s
Build and Push Docker Image / build-app (amd64, linux/amd64, ubuntu-latest) (push) Canceled after 0s
Build and Push Docker Image / build-app (arm64, linux/arm64, ubuntu-24.04-arm) (push) Canceled after 0s
DocReader / Python tests and Go client tests (push) Canceled after 0s
Build & Publish (dsh-weknora) / Typecheck, test, pack (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (pinned) (push) Canceled after 0s
Build & Publish (dsh-weknora) / End-to-end inside dsh (latest, advisory) (push) Canceled after 0s
Frontend / Test, type-check, and build (push) Canceled after 0s
Go Lint Cache / warm lint cache (.) (push) Canceled after 0s
Go Lint Cache / warm lint cache (cli) (push) Canceled after 0s
Go Lint Cache / warm lint cache (client) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.10) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.11) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.12) (push) Canceled after 0s
Build & Publish (mcp-server) / Test (Python 3.13) (push) Canceled after 0s
Build and Push Docker Image / merge (push) Canceled after 0s
Build & Publish (dsh-weknora) / Publish to npm (push) Canceled after 0s
Build & Publish (mcp-server) / Build sdist + wheel (push) Canceled after 0s
Build & Publish (mcp-server) / Publish to PyPI (push) Canceled after 0s
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
|
||||
func TestFinalizeIndexedKnowledgeState(t *testing.T) {
|
||||
now := time.Date(2026, 5, 20, 12, 0, 0, 0, time.UTC)
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
hasPendingMultimodal bool
|
||||
textChunkCount int
|
||||
wantParseStatus string
|
||||
wantSummaryStatus string
|
||||
wantErrorMessage string
|
||||
}{
|
||||
{
|
||||
name: "text document stays processing so post-process can fan out enrichment",
|
||||
textChunkCount: 2,
|
||||
wantParseStatus: types.ParseStatusProcessing,
|
||||
wantSummaryStatus: types.SummaryStatusNone,
|
||||
// Still processing: FinalizeSubtask clears the column when this
|
||||
// row is eventually promoted to completed.
|
||||
wantErrorMessage: "previous attempt failed",
|
||||
},
|
||||
{
|
||||
name: "empty indexed document is completed without summary work",
|
||||
textChunkCount: 0,
|
||||
wantParseStatus: types.ParseStatusCompleted,
|
||||
wantSummaryStatus: types.SummaryStatusNone,
|
||||
wantErrorMessage: "",
|
||||
},
|
||||
{
|
||||
name: "document waits while multimodal image work is pending",
|
||||
hasPendingMultimodal: true,
|
||||
textChunkCount: 2,
|
||||
wantParseStatus: types.ParseStatusProcessing,
|
||||
wantSummaryStatus: types.SummaryStatusNone,
|
||||
wantErrorMessage: "previous attempt failed",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
knowledge := &types.Knowledge{
|
||||
ParseStatus: types.ParseStatusProcessing,
|
||||
SummaryStatus: types.SummaryStatusCompleted,
|
||||
ErrorMessage: "previous attempt failed",
|
||||
}
|
||||
|
||||
finalizeIndexedKnowledgeState(knowledge, 4096, tt.textChunkCount, tt.hasPendingMultimodal, now)
|
||||
|
||||
if knowledge.ErrorMessage != tt.wantErrorMessage {
|
||||
t.Fatalf("ErrorMessage = %q, want %q", knowledge.ErrorMessage, tt.wantErrorMessage)
|
||||
}
|
||||
|
||||
if knowledge.ParseStatus != tt.wantParseStatus {
|
||||
t.Fatalf("ParseStatus = %q, want %q", knowledge.ParseStatus, tt.wantParseStatus)
|
||||
}
|
||||
if knowledge.SummaryStatus != tt.wantSummaryStatus {
|
||||
t.Fatalf("SummaryStatus = %q, want %q", knowledge.SummaryStatus, tt.wantSummaryStatus)
|
||||
}
|
||||
if knowledge.EnableStatus != "enabled" {
|
||||
t.Fatalf("EnableStatus = %q, want enabled", knowledge.EnableStatus)
|
||||
}
|
||||
if knowledge.StorageSize != 4096 {
|
||||
t.Fatalf("StorageSize = %d, want 4096", knowledge.StorageSize)
|
||||
}
|
||||
if knowledge.ProcessedAt == nil || !knowledge.ProcessedAt.Equal(now) {
|
||||
t.Fatalf("ProcessedAt = %v, want %v", knowledge.ProcessedAt, now)
|
||||
}
|
||||
if !knowledge.UpdatedAt.Equal(now) {
|
||||
t.Fatalf("UpdatedAt = %v, want %v", knowledge.UpdatedAt, now)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestMarkKnowledgeProcessingClearsPreviousAttemptError covers the transition
|
||||
// every worker performs before it starts a new attempt. A row that failed
|
||||
// earlier still carries that attempt's error_message, and leaving it in place
|
||||
// makes the UI report a failure on a document it is simultaneously showing as
|
||||
// processing.
|
||||
func TestMarkKnowledgeProcessingClearsPreviousAttemptError(t *testing.T) {
|
||||
now := time.Date(2026, 5, 20, 12, 0, 0, 0, time.UTC)
|
||||
knowledge := &types.Knowledge{
|
||||
ParseStatus: types.ParseStatusFailed,
|
||||
ErrorMessage: "Task interrupted due to application restart",
|
||||
}
|
||||
|
||||
markKnowledgeProcessing(knowledge, now)
|
||||
|
||||
if knowledge.ParseStatus != types.ParseStatusProcessing {
|
||||
t.Fatalf("ParseStatus = %q, want %q", knowledge.ParseStatus, types.ParseStatusProcessing)
|
||||
}
|
||||
if knowledge.ErrorMessage != "" {
|
||||
t.Fatalf("ErrorMessage = %q, want empty", knowledge.ErrorMessage)
|
||||
}
|
||||
if !knowledge.UpdatedAt.Equal(now) {
|
||||
t.Fatalf("UpdatedAt = %v, want %v", knowledge.UpdatedAt, now)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user