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,79 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/Tencent/WeKnora/internal/types"
|
||||
)
|
||||
|
||||
func TestScopeClause_KnowledgeAndFullKBOredTogether(t *testing.T) {
|
||||
sql, args := scopeClause(
|
||||
[]string{"kb-1"},
|
||||
[]string{"doc-9"},
|
||||
nil,
|
||||
map[string]uint64{"kb-1": 7},
|
||||
)
|
||||
|
||||
if !strings.Contains(sql, "chunks.knowledge_id IN ?") {
|
||||
t.Fatalf("expected knowledge-id predicate, got %q", sql)
|
||||
}
|
||||
if !strings.Contains(sql, "chunks.knowledge_base_id = ? AND chunks.tenant_id = ?") {
|
||||
t.Fatalf("expected kb-tenant predicate, got %q", sql)
|
||||
}
|
||||
if !strings.Contains(sql, " OR ") {
|
||||
t.Fatalf("expected the two scopes to be OR'd, got %q", sql)
|
||||
}
|
||||
// args: knowledgeIDs slice + kbID + tenantID
|
||||
if len(args) != 3 {
|
||||
t.Fatalf("expected 3 args, got %d: %v", len(args), args)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScopeClause_TagScopeUsesExistsInsteadOfExpandedKnowledgeIDs(t *testing.T) {
|
||||
sql, args := scopeClause(
|
||||
nil,
|
||||
nil,
|
||||
[]*types.SearchTarget{{
|
||||
KnowledgeBaseID: "kb-1",
|
||||
TenantID: 7,
|
||||
TagIDs: []string{"tag-a", "tag-b"},
|
||||
}},
|
||||
map[string]uint64{"kb-1": 7},
|
||||
)
|
||||
|
||||
if strings.Contains(sql, "chunks.knowledge_id IN ?") {
|
||||
t.Fatalf("tag scope must not expand to knowledge-id IN predicate, got %q", sql)
|
||||
}
|
||||
if !strings.Contains(sql, "EXISTS") || !strings.Contains(sql, "knowledge_tag_relations") {
|
||||
t.Fatalf("expected tag relation EXISTS predicate, got %q", sql)
|
||||
}
|
||||
if !strings.Contains(sql, "ktr.tag_id IN ?") {
|
||||
t.Fatalf("expected tag-id predicate, got %q", sql)
|
||||
}
|
||||
if len(args) != 3 {
|
||||
t.Fatalf("expected kbID, tenantID, tagIDs args, got %d: %v", len(args), args)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScopeClause_SkipsKBWithoutTenant(t *testing.T) {
|
||||
sql, args := scopeClause(
|
||||
[]string{"kb-1", "kb-2"},
|
||||
nil,
|
||||
nil,
|
||||
map[string]uint64{"kb-1": 7}, // kb-2 has no tenant mapping
|
||||
)
|
||||
if strings.Contains(sql, "kb-2") {
|
||||
t.Fatalf("kb-2 has no tenant and must be skipped, got %q", sql)
|
||||
}
|
||||
if len(args) != 2 {
|
||||
t.Fatalf("expected only kb-1 (2 args), got %d: %v", len(args), args)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScopeClause_EmptyWhenNoUsableScope(t *testing.T) {
|
||||
sql, args := scopeClause([]string{"kb-1"}, nil, nil, map[string]uint64{})
|
||||
if sql != "" || args != nil {
|
||||
t.Fatalf("expected empty scope, got sql=%q args=%v", sql, args)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user