8febe12d7d
真实本机 PG/ES/MinIO:v071 目录镜像 10 模式、结构引用/游标 15 模式、 8 表×2 外部范围身份矩阵、13 模式自然键(含软删除与合法同 parent 正例)、 备份期间三注入、收尾故障与授权撤销两个真实治理 PG 用例。 需隔离服务的用例在 test-scope.json 显式声明:普通 CI 跳过不算通过。
48 lines
1.4 KiB
Go
48 lines
1.4 KiB
Go
package v071
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestContractEvidenceRejectsAncestorSymlinkBeforeWrite(t *testing.T) {
|
|
root := t.TempDir()
|
|
outside := t.TempDir()
|
|
if err := os.Symlink(outside, filepath.Join(root, "effects")); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := persistImmutableJSON(filepath.Join(root, "effects", "job", "index", "id", "intent.json"), []byte(`{"intent":true}`)); err == nil {
|
|
t.Fatal("ancestor symlink accepted")
|
|
}
|
|
entries, err := os.ReadDir(outside)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if len(entries) != 0 {
|
|
t.Fatal("refusal wrote through ancestor symlink")
|
|
}
|
|
}
|
|
|
|
func TestContractEvidenceSyncsEveryAncestorAndPropagatesFailure(t *testing.T) {
|
|
root := t.TempDir()
|
|
leaf := filepath.Join(root, "effects", "plan", "index", "id")
|
|
synced := map[string]bool{}
|
|
if err := ensureEvidenceDirectory(leaf, func(path string) error { synced[path] = true; return syncEvidenceDirectory(path) }); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for path := filepath.Dir(leaf); ; path = filepath.Dir(path) {
|
|
if !synced[path] {
|
|
t.Fatalf("unsynced directory entry parent: %s", path)
|
|
}
|
|
if filepath.Dir(path) == path {
|
|
break
|
|
}
|
|
}
|
|
failure := errors.New("injected directory fsync error")
|
|
if err := ensureEvidenceDirectory(leaf, func(string) error { return failure }); !errors.Is(err, failure) {
|
|
t.Fatalf("fsync error not propagated: %v", err)
|
|
}
|
|
}
|