Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bf049cee1f | |||
| 55fba5fc0e | |||
| ce2f90c1c5 |
@@ -1,5 +1,26 @@
|
||||
# Changelog
|
||||
|
||||
## 开发快照 snapshot/v0.1.100 - 2026-10-28
|
||||
|
||||
### Fixed
|
||||
|
||||
- 测试封存暂停共享写入服务前及暂停后,强制检查整个源数据库的解析状态、待处理任务和死信;其他库、其他租户及已删除或未知任务范围的未完成工作均阻断封存。
|
||||
- 保留部署侧入口与后台作业检查;数据库任务结清不代表 Wiki 语义验收通过。本次未清理死信、未暂停实际测试 WeKnora、未执行生产发布。
|
||||
|
||||
## 开发快照 snapshot/v0.1.99 - 2026-10-28
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复整库归档将 Wiki 页面与问题记录的字符串状态误按分块整数状态解析的问题;分块状态仅在分块表中解析,Wiki 状态和正文原样保留。
|
||||
- 候选捕获回归改用非空 Wiki 页面与问题记录,防止空表夹具漏检。本次仍不代表完整同步恢复业务已交付。
|
||||
|
||||
## 开发快照 snapshot/v0.1.98 - 2026-10-28
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复整库候选封存只单向校验搜索索引的问题:数据库标记为已索引的分块必须在导出索引中存在,否则拒绝封存;按分块身份而非总数量核对,避免重复索引掩盖缺失。仅存储的父分块仍允许不建索引。
|
||||
- 本修复增强候选完整性,不代表整库业务入口、生产同步恢复或语义验收已经完成。
|
||||
|
||||
## 开发快照 snapshot/v0.1.97 - 2026-10-28
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -101,4 +101,4 @@
|
||||
|
||||
已新增 `internal/releaseadapter/v071/library_capture.go`,在源服务组互斥下串起预检、暂停、停后复检、PG/ES 导出、独立归档和恢复。协调测试使用 PG/服务控制夹具与 HTTP 搜索夹具,覆盖预检忙时零停止、暂停前后新增任务阻断、搜索失败恢复、旧作业重放不重新暂停、跨 scope 复用拒绝、归档丢失不返回成功;不把这组夹具当成实际业务知识库全链路验收。最终竞态回归、隔离 Docker 重跑与 `make verify` 均退出码 0,最终日志为同目录 `kg-freeze-docker-final.log`、`kg-library-freeze-final-verify.log`。
|
||||
|
||||
**仍缺少的接线**:真实测试部署的全部写入者枚举及标签/健康契约、全源任务就绪检查的实际提供方、worker 调用捕获协调函数、启动恢复入口和持续恢复调度。单独的本地 Docker 控制器不能控制远端测试主机;远端场景需在测试主机运行受限执行器,不能向浏览器或普通 API 暴露 Docker socket。上述测试不能证明这些接线已完成,尚未暂停实际测试 WeKnora。
|
||||
**仍缺少的接线**:真实测试部署的全部写入者枚举及标签/健康契约、部署侧入口及后台作业就绪检查的实际提供方、worker 调用捕获协调函数、启动恢复入口和持续恢复调度。`CaptureLibrary` 已强制在暂停前后检查整个源数据库的解析、pending 与 dead-letter 状态(跨库、跨租户及未知/删除范围);此检查不能代替入口隔离与 Wiki 语义验收。单独的本地 Docker 控制器不能控制远端测试主机;远端场景需在测试主机运行受限执行器,不能向浏览器或普通 API 暴露 Docker socket。上述测试不能证明这些接线已完成,尚未暂停实际测试 WeKnora。
|
||||
|
||||
@@ -116,6 +116,7 @@ type libraryRow struct {
|
||||
OwnerType string `json:"owner_type"`
|
||||
OwnerID string `json:"owner_id"`
|
||||
Content string `json:"content"`
|
||||
ChunkStatus int `json:"-"`
|
||||
}
|
||||
|
||||
func validateLibraryCandidate(identity PostgresIdentity, pg PostgresSnapshot, es SearchSnapshot) error {
|
||||
@@ -151,6 +152,17 @@ func validateLibraryCandidate(identity PostgresIdentity, pg PostgresSnapshot, es
|
||||
if json.Unmarshal(raw, &row) != nil {
|
||||
return errors.New("invalid library content row")
|
||||
}
|
||||
// Status is table-specific: chunks use integers, Wiki pages/issues
|
||||
// use strings. Decode chunk metadata only for its owning table.
|
||||
if table.Name == "chunks" {
|
||||
var metadata struct {
|
||||
Status int `json:"status"`
|
||||
}
|
||||
if json.Unmarshal(raw, &metadata) != nil {
|
||||
return errors.New("invalid library chunk status")
|
||||
}
|
||||
row.ChunkStatus = metadata.Status
|
||||
}
|
||||
if table.Name == "knowledge_tag_relations" {
|
||||
if !validSearchIdentifier(row.KnowledgeID) || !validSearchIdentifier(row.TagID) {
|
||||
return errors.New("invalid library tag relation")
|
||||
@@ -220,6 +232,7 @@ func validateLibraryCandidate(identity PostgresIdentity, pg PostgresSnapshot, es
|
||||
return errors.New("invalid library index digest")
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
indexedChunks := map[string]bool{}
|
||||
for _, document := range es.Documents {
|
||||
var row libraryRow
|
||||
if json.Unmarshal(document.Source, &row) != nil || !validSearchIdentifier(document.ID) || seen[document.ID] {
|
||||
@@ -233,6 +246,15 @@ func validateLibraryCandidate(identity PostgresIdentity, pg PostgresSnapshot, es
|
||||
if !searchHitMatches(document.Source, SearchIdentity{TenantID: identity.TenantID, KnowledgeBaseID: identity.KnowledgeBaseID, KnowledgeID: row.KnowledgeID}) {
|
||||
return errors.New("cross-scope library index")
|
||||
}
|
||||
indexedChunks[row.ChunkID] = true
|
||||
}
|
||||
// v0.7.1 ChunkStatusIndexed is 2. One chunk can have several search
|
||||
// records, so compare identities rather than counts. Stored-only parent
|
||||
// chunks intentionally have no index and must not be rejected as missing.
|
||||
for id, chunk := range tables["chunks"] {
|
||||
if chunk.ChunkStatus == 2 && !indexedChunks[id] {
|
||||
return errors.New("missing indexed library chunk")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -88,7 +88,14 @@ func libraryCandidateFixture() (PostgresSnapshot, SearchSnapshot, *libraryCandid
|
||||
newTableSnapshot("resources", []json.RawMessage{json.RawMessage(`{"id":"res-safe","tenant_id":10000,"handle":"ABCDEFGHIJKLMNOPQRSTUV","provider":"oss","physical_path":"oss://fixture/source.txt","size":4}`)}),
|
||||
}
|
||||
for _, name := range []string{"resource_bindings", "knowledge_tags", "knowledge_tag_relations", "wiki_folders", "wiki_pages", "wiki_page_issues", "wiki_log_entries"} {
|
||||
tables = append(tables, newTableSnapshot(name, nil))
|
||||
var rows []json.RawMessage
|
||||
switch name {
|
||||
case "wiki_pages":
|
||||
rows = []json.RawMessage{json.RawMessage(`{"id":"wiki-safe","tenant_id":10000,"knowledge_base_id":"kb-safe","status":"published","content":"complete wiki body"}`)}
|
||||
case "wiki_page_issues":
|
||||
rows = []json.RawMessage{json.RawMessage(`{"id":"issue-safe","tenant_id":10000,"knowledge_base_id":"kb-safe","status":"open"}`)}
|
||||
}
|
||||
tables = append(tables, newTableSnapshot(name, rows))
|
||||
}
|
||||
es := SearchSnapshot{MappingSHA256: shaBytes([]byte("mapping")), Documents: []SearchDocument{{ID: "es-safe", Source: json.RawMessage(`{"knowledge_base_id":"kb-safe","knowledge_id":"doc-safe","chunk_id":"chunk-safe","content":"chunk"}`)}}}
|
||||
es.DocumentsSHA256, _ = searchDocumentsDigest(es.Documents)
|
||||
|
||||
@@ -28,6 +28,9 @@ func CaptureLibrary(ctx context.Context, freeze *libraryfreeze.Coordinator, arch
|
||||
return libraryfreeze.Result{}, errors.New("invalid library capture configuration")
|
||||
}
|
||||
result, err := freeze.RunPrepared(ctx, req.JobID, func(ctx context.Context) error {
|
||||
if err := checkLibrarySourceSettlement(ctx, db); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := sourceReady(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -36,6 +39,9 @@ func CaptureLibrary(ctx context.Context, freeze *libraryfreeze.Coordinator, arch
|
||||
_, err := ExportLibrary(ctx, db, req.Identity)
|
||||
return err
|
||||
}, func(ctx context.Context) (string, error) {
|
||||
if err := checkLibrarySourceSettlement(ctx, db); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := sourceReady(ctx); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -15,10 +15,11 @@ import (
|
||||
)
|
||||
|
||||
type captureWriter struct {
|
||||
running atomic.Bool
|
||||
db *libraryFixture
|
||||
late bool
|
||||
stops int
|
||||
running atomic.Bool
|
||||
db *libraryFixture
|
||||
late bool
|
||||
lateSource bool
|
||||
stops int
|
||||
}
|
||||
|
||||
func (c *captureWriter) Inventory(context.Context) ([]libraryfreeze.Service, error) {
|
||||
@@ -31,14 +32,20 @@ func (c *captureWriter) Stop(context.Context, string) error {
|
||||
if c.late {
|
||||
c.db.tx.pending = 1
|
||||
}
|
||||
if c.lateSource {
|
||||
c.db.tx.sourcePending = 1
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (c *captureWriter) Start(context.Context, string) error { c.running.Store(true); return nil }
|
||||
func TestLibraryCaptureMaintenanceOwnsArchiveAndRestoresOnFailure(t *testing.T) {
|
||||
for _, mode := range []string{"success", "initial-busy", "late-pending", "search-failure"} {
|
||||
for _, mode := range []string{"success", "initial-busy", "late-pending", "search-failure", "other-library-busy", "other-library-late-pending"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
db := newLibraryFixture()
|
||||
writer := &captureWriter{db: db, late: mode == "late-pending"}
|
||||
writer := &captureWriter{db: db, late: mode == "late-pending", lateSource: mode == "other-library-late-pending"}
|
||||
if mode == "other-library-busy" {
|
||||
db.tx.sourcePending = 1
|
||||
}
|
||||
writer.running.Store(true)
|
||||
if mode == "initial-busy" {
|
||||
db.tx.pending = 1
|
||||
@@ -98,7 +105,7 @@ func TestLibraryCaptureMaintenanceOwnsArchiveAndRestoresOnFailure(t *testing.T)
|
||||
if err == nil {
|
||||
t.Fatal("invalid candidate succeeded")
|
||||
}
|
||||
if mode == "initial-busy" && writer.stops != 0 {
|
||||
if (mode == "initial-busy" || mode == "other-library-busy") && writer.stops != 0 {
|
||||
t.Fatal("busy source stopped")
|
||||
}
|
||||
return
|
||||
|
||||
@@ -54,6 +54,38 @@ func TestLibraryExportIsolatedPostgres(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
t.Run("whole source settlement", func(t *testing.T) {
|
||||
if err := checkLibrarySourceSettlement(ctx, db); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, tc := range []struct{ name, change, restore string }{
|
||||
{"other tenant document", `UPDATE knowledges SET parse_status='processing' WHERE id='other-scope'`, `UPDATE knowledges SET parse_status='completed' WHERE id='other-scope'`},
|
||||
{"other library pending", `INSERT INTO task_pending_ops VALUES(20000,'wiki:ingest','knowledge_base','other-library')`, `DELETE FROM task_pending_ops`},
|
||||
{"deleted scope pending", `INSERT INTO task_pending_ops VALUES(20000,'wiki:retract','knowledge','physically-deleted-doc')`, `DELETE FROM task_pending_ops`},
|
||||
{"unknown scope pending", `INSERT INTO task_pending_ops VALUES(20000,'unknown:task','unknown','unknown')`, `DELETE FROM task_pending_ops`},
|
||||
{"other tenant dead letter", `INSERT INTO task_dead_letters VALUES(20000,'document:process','knowledge_base','other-library')`, `DELETE FROM task_dead_letters`},
|
||||
} {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
if _, err := db.Exec(ctx, tc.change); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
if _, err := db.Exec(ctx, tc.restore); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
})
|
||||
if _, err := ExportLibrary(ctx, db, scope); err != nil {
|
||||
t.Fatalf("selected library unexpectedly busy: %v", err)
|
||||
}
|
||||
if err := checkLibrarySourceSettlement(ctx, db); err == nil {
|
||||
t.Fatal("source maintenance allowed while another scope has unfinished work")
|
||||
}
|
||||
})
|
||||
}
|
||||
if err := checkLibrarySourceSettlement(ctx, db); err != nil {
|
||||
t.Fatalf("settled source did not recover: %v", err)
|
||||
}
|
||||
})
|
||||
t.Run("MVCC concurrent update", func(t *testing.T) {
|
||||
wrapper := libraryHookDB{pool: db, hook: func() {
|
||||
if _, err := db.Exec(ctx, `UPDATE wiki_pages SET content='new-content' WHERE id='wiki-safe'`); err != nil {
|
||||
|
||||
@@ -80,6 +80,7 @@ type libraryFixtureTx struct {
|
||||
pgx.Tx
|
||||
queries []string
|
||||
committed bool
|
||||
sourcePending int64
|
||||
pending, failed, unsettled int64
|
||||
graph bool
|
||||
queryError bool
|
||||
@@ -111,6 +112,10 @@ type libraryFixtureRow struct {
|
||||
|
||||
func (r libraryFixtureRow) Scan(dest ...any) error {
|
||||
switch {
|
||||
case strings.Contains(r.sql, "library-source-settlement"):
|
||||
*dest[0].(*int64) = r.d.unsettled
|
||||
*dest[1].(*int64) = r.d.pending + r.d.sourcePending
|
||||
*dest[2].(*int64) = r.d.failed
|
||||
case strings.Contains(r.sql, "schema_migrations"):
|
||||
*dest[0].(*int) = 74
|
||||
*dest[1].(*bool) = false
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package v071
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"knowledge-governance/internal/librarysnapshot"
|
||||
)
|
||||
|
||||
func TestLibraryCandidateIndexCompletenessUsesChunkIdentity(t *testing.T) {
|
||||
for _, mode := range []string{"stored-parent", "multiple-records-one-chunk", "same-count-missing-chunk"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
pg, es, _ := libraryCandidateFixture()
|
||||
rows := []json.RawMessage{json.RawMessage(`{"id":"chunk-safe","tenant_id":10000,"knowledge_base_id":"kb-safe","knowledge_id":"doc-safe","content":"chunk","status":2,"chunk_type":"text"}`)}
|
||||
if mode == "stored-parent" {
|
||||
rows = append(rows, json.RawMessage(`{"id":"parent-safe","tenant_id":10000,"knowledge_base_id":"kb-safe","knowledge_id":"doc-safe","content":"context","status":1,"chunk_type":"parent_text"}`))
|
||||
} else {
|
||||
es.Documents = append(es.Documents, SearchDocument{ID: "es-second", Source: append(json.RawMessage(nil), es.Documents[0].Source...)})
|
||||
if mode == "same-count-missing-chunk" {
|
||||
rows = append(rows, json.RawMessage(`{"id":"chunk-second","tenant_id":10000,"knowledge_base_id":"kb-safe","knowledge_id":"doc-safe","content":"second","status":2,"chunk_type":"text"}`))
|
||||
}
|
||||
}
|
||||
pg.Tables[1] = newTableSnapshot("chunks", rows)
|
||||
es.DocumentsSHA256, _ = searchDocumentsDigest(es.Documents)
|
||||
err := validateLibraryCandidate(PostgresIdentity{TenantID: 10000, KnowledgeBaseID: "kb-safe"}, pg, es)
|
||||
if mode == "same-count-missing-chunk" {
|
||||
if err == nil || !strings.Contains(err.Error(), "missing indexed library chunk") {
|
||||
t.Fatalf("same counts masked a missing chunk: %v", err)
|
||||
}
|
||||
} else if err != nil {
|
||||
t.Fatalf("valid index shape rejected: %v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestLibraryCandidateRejectsMissingIndexedChunk(t *testing.T) {
|
||||
pg, es, objects := libraryCandidateFixture()
|
||||
pg.Tables[1] = newTableSnapshot("chunks", []json.RawMessage{json.RawMessage(`{"id":"chunk-safe","tenant_id":10000,"knowledge_base_id":"kb-safe","knowledge_id":"doc-safe","content":"chunk","status":2,"chunk_type":"text"}`)})
|
||||
identity := PostgresIdentity{TenantID: 10000, KnowledgeBaseID: "kb-safe"}
|
||||
if err := validateLibraryCandidate(identity, pg, es); err != nil {
|
||||
t.Fatalf("complete indexed chunk rejected: %v", err)
|
||||
}
|
||||
es.Documents = nil
|
||||
es.DocumentsSHA256, _ = searchDocumentsDigest(es.Documents)
|
||||
root := t.TempDir()
|
||||
if err := os.Chmod(root, 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
archive, err := librarysnapshot.Open(root, 1024*1024)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer archive.Close()
|
||||
contract := librarysnapshot.Compatibility{WeKnoraVersion: "v0.7.1", SchemaVersion: 74, RetrieverEngine: "elasticsearch_v8", EmbeddingModel: "fixture-model", EmbeddingDimension: 1024, IndexMappingSHA256: es.MappingSHA256}
|
||||
id, err := ArchiveLibraryCandidate(context.Background(), archive, "internal", identity, contract, pg, es, objects, time.Now().UTC())
|
||||
if err == nil || id != "" {
|
||||
t.Fatal("sealed a supposedly complete library with an indexed PostgreSQL chunk missing from Elasticsearch")
|
||||
}
|
||||
if !strings.Contains(err.Error(), "missing indexed library chunk") {
|
||||
t.Fatalf("unexpected refusal: %v", err)
|
||||
}
|
||||
versions, err := os.ReadDir(root + "/versions")
|
||||
if err != nil || len(versions) != 0 {
|
||||
t.Fatalf("incomplete candidate became visible: versions=%d err=%v", len(versions), err)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package v071
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
)
|
||||
|
||||
// A maintenance window stops a shared writer, not a single KB. Check its entire
|
||||
// source database, including other tenants, deleted scopes and unknown task
|
||||
// scopes. Restricting this query to the selected KB can interrupt another job.
|
||||
// This only establishes recorded processing settlement, never Wiki semantics or
|
||||
// the absence of unrecorded/remote work; CaptureLibrary still requires the
|
||||
// deployment's ingress and background-worker readiness callback.
|
||||
func checkLibrarySourceSettlement(ctx context.Context, db librarySnapshotDB) error {
|
||||
tx, err := db.BeginTx(ctx, pgx.TxOptions{IsoLevel: pgx.RepeatableRead, AccessMode: pgx.ReadOnly})
|
||||
if err != nil {
|
||||
return errors.New("begin library source settlement")
|
||||
}
|
||||
defer tx.Rollback(context.WithoutCancel(ctx))
|
||||
var unsettled, pending, failed int64
|
||||
if err := tx.QueryRow(ctx, librarySourceSettlementSQL).Scan(&unsettled, &pending, &failed); err != nil {
|
||||
return errors.New("read library source settlement")
|
||||
}
|
||||
if unsettled != 0 || pending != 0 || failed != 0 {
|
||||
return errors.New("library source has unfinished or failed processing")
|
||||
}
|
||||
if err := tx.Commit(ctx); err != nil {
|
||||
return errors.New("commit library source settlement")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
const librarySourceSettlementSQL = `SELECT /* library-source-settlement */
|
||||
(SELECT count(*) FROM knowledges WHERE deleted_at IS NULL AND (parse_status IS DISTINCT FROM 'completed' OR pending_subtasks_count IS NULL OR pending_subtasks_count<>0)),
|
||||
(SELECT count(*) FROM task_pending_ops),
|
||||
(SELECT count(*) FROM task_dead_letters)`
|
||||
@@ -0,0 +1,80 @@
|
||||
package v071
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"knowledge-governance/internal/librarysnapshot"
|
||||
)
|
||||
|
||||
func TestLibraryCandidateArchivesWikiStringStatuses(t *testing.T) {
|
||||
for _, tc := range []struct{ table, status string }{
|
||||
{"wiki_pages", "draft"}, {"wiki_pages", "published"}, {"wiki_pages", "archived"},
|
||||
{"wiki_page_issues", "open"}, {"wiki_page_issues", "resolved"},
|
||||
} {
|
||||
t.Run(tc.table+"/"+tc.status, func(t *testing.T) {
|
||||
pg, es, objects := libraryCandidateFixture()
|
||||
raw := json.RawMessage(`{"id":"wiki-safe","tenant_id":10000,"knowledge_base_id":"kb-safe","content":"complete wiki body","status":"` + tc.status + `"}`)
|
||||
for i := range pg.Tables {
|
||||
if pg.Tables[i].Name == tc.table {
|
||||
pg.Tables[i] = newTableSnapshot(tc.table, []json.RawMessage{raw})
|
||||
}
|
||||
}
|
||||
root := t.TempDir()
|
||||
if err := os.Chmod(root, 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
archive, err := librarysnapshot.Open(root, 1024*1024)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer archive.Close()
|
||||
contract := librarysnapshot.Compatibility{WeKnoraVersion: "v0.7.1", SchemaVersion: 74, RetrieverEngine: "elasticsearch_v8", EmbeddingModel: "fixture-model", EmbeddingDimension: 1024, IndexMappingSHA256: es.MappingSHA256}
|
||||
id, err := ArchiveLibraryCandidate(context.Background(), archive, "internal", PostgresIdentity{TenantID: 10000, KnowledgeBaseID: "kb-safe"}, contract, pg, es, objects, time.Now().UTC())
|
||||
if err != nil {
|
||||
t.Fatalf("valid Wiki string status rejected: %v", err)
|
||||
}
|
||||
saved, err := archive.Load(id)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
found := false
|
||||
for _, part := range saved.Parts {
|
||||
if part.Name != tc.table {
|
||||
continue
|
||||
}
|
||||
found = true
|
||||
r, e := archive.OpenPart(part)
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
data, e := io.ReadAll(r)
|
||||
r.Close()
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
var rows []json.RawMessage
|
||||
if e = json.Unmarshal(data, &rows); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if len(rows) != 1 {
|
||||
t.Fatalf("wiki rows=%d", len(rows))
|
||||
}
|
||||
var row map[string]any
|
||||
if e = json.Unmarshal(rows[0], &row); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if row["status"] != tc.status || row["content"] != "complete wiki body" {
|
||||
t.Fatal("Wiki status/body changed in archive")
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Fatal("Wiki part missing")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user