فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
test(a02): cover unique indexes, included columns and self-referential foreign keys in private schema manifest
davoodmehraban89 committed
Oct 30, 2026 at 20:38 UTC
9a7939d51c49d844acf85d4b4635186150a4d3de
1 file changed
+20
-7
scripts/a02-synthetic-sql-localdb-restore-smoke.ps1
+20
-7
@@ -65,8 +65,11 @@ try{
65
$conn.Open()
66
$phase='create-synthetic-database'
67
ExecSql $conn ('CREATE DATABASE ['+$source+'];')
68
- ExecSql $conn ('CREATE TABLE ['+$source+'].dbo.A02Synthetic(id int NOT NULL PRIMARY KEY,amount bigint NOT NULL);'+
69
- 'INSERT INTO ['+$source+'].dbo.A02Synthetic(id,amount) VALUES(1,12345),(2,67890);')
68
+ ExecSql $conn ('CREATE TABLE ['+$source+'].dbo.A02Synthetic('+
69
+ 'id int NOT NULL PRIMARY KEY,amount bigint NOT NULL,parentId int NULL,'+
70
+ 'CONSTRAINT FK_A02Synthetic_Parent FOREIGN KEY(parentId) REFERENCES dbo.A02Synthetic(id));'+
71
+ 'CREATE UNIQUE INDEX UX_A02Synthetic_Amount ON ['+$source+'].dbo.A02Synthetic(amount) INCLUDE(parentId);'+
72
+ 'INSERT INTO ['+$source+'].dbo.A02Synthetic(id,amount,parentId) VALUES(1,12345,NULL),(2,67890,1);')
73
$phase='create-synthetic-backup'
74
$bak=Join-Path $folder 'synthetic_copy_only.bak'
75
ExecSql $conn ('BACKUP DATABASE ['+$source+'] TO DISK = '+(Literal $bak)+' WITH INIT,COPY_ONLY;')
@@ -104,7 +107,8 @@ try{
107
$inventory=($inventoryLines | Out-String | ConvertFrom-Json)
108
$validFingerprint=([string]$inventory.fingerprintSha256 -cmatch '^[0-9a-f]{64}$')
109
$accepted=($inventory.status -eq 'isolated-schema-inventoried' -and
107
- $inventory.tableCount -eq 1 -and $inventory.columnCount -eq 2 -and
110
+ $inventory.tableCount -eq 1 -and $inventory.columnCount -eq 3 -and
111
+ $inventory.primaryKeyCount -eq 1 -and $inventory.foreignKeyCount -eq 1 -and
112
$validFingerprint -and $inventory.userRowsRead -eq $false -and
113
$inventory.databaseModified -eq $false -and $inventory.canImport -eq $false)
114
Require $accepted 'A02_SCHEMA_INVENTORY_CONTRACT_FAILED'
@@ -115,8 +119,8 @@ try{
119
Require ($LASTEXITCODE -eq 0) 'A02_PRIVATE_SCHEMA_MANIFEST_CREATE_FAILED'
120
$manifestStatus=($manifestOutput | Out-String | ConvertFrom-Json)
121
Require ($manifestStatus.status -eq 'private-schema-manifest-encrypted' -and
118
- $manifestStatus.tableCount -eq 1 -and $manifestStatus.columnCount -eq 2 -and
119
- $manifestStatus.primaryKeyCount -eq 1 -and $manifestStatus.foreignKeyCount -eq 0 -and
122
+ $manifestStatus.tableCount -eq 1 -and $manifestStatus.columnCount -eq 3 -and
123
+ $manifestStatus.primaryKeyCount -eq 1 -and $manifestStatus.foreignKeyCount -eq 1 -and
124
$manifestStatus.dpapiScope -eq 'CurrentUser' -and
125
$manifestStatus.fileAclRestricted -eq $true -and
126
$manifestStatus.userRowsRead -eq $false -and
@@ -136,10 +140,19 @@ try{
140
$privateManifest.schemaFingerprintSha256 -cmatch '^[0-9a-f]{64}$' -and
141
$privateManifest.tables.Count -eq 1 -and
142
$privateManifest.tables[0].name -eq 'A02Synthetic' -and
139
- $privateManifest.tables[0].columns.Count -eq 2 -and
140
- $privateManifest.tables[0].indexes.Count -eq 1 -and
143
+ $privateManifest.tables[0].columns.Count -eq 3 -and
144
+ $privateManifest.tables[0].indexes.Count -eq 2 -and
145
+ $privateManifest.tables[0].foreignKeys.Count -eq 1 -and
146
$privateManifest.tables[0].indexes[0].primaryKey -eq $true -and
147
$privateManifest.tables[0].indexes[0].keyColumns[0].name -eq 'id' -and
148
+ $privateManifest.tables[0].indexes[1].name -eq 'UX_A02Synthetic_Amount' -and
149
+ $privateManifest.tables[0].indexes[1].keyColumns[0].name -eq 'amount' -and
150
+ $privateManifest.tables[0].indexes[1].includedColumns[0] -eq 'parentId' -and
151
+ $privateManifest.tables[0].foreignKeys[0].name -eq 'FK_A02Synthetic_Parent' -and
152
+ $privateManifest.tables[0].foreignKeys[0].referencedTable -eq 'A02Synthetic' -and
153
+ $privateManifest.tables[0].foreignKeys[0].columns[0].column -eq 'parentId' -and
154
+ $privateManifest.tables[0].foreignKeys[0].columns[0].referencedColumn -eq 'id' -and
155
+ $privateManifest.tables[0].foreignKeys[0].deleteAction -eq 'NO_ACTION' -and
156
$privateManifest.userRowsRead -eq $false -and
157
$privateManifest.databaseModified -eq $false -and
158
$privateManifest.canImport -eq $false) 'A02_PRIVATE_SCHEMA_MANIFEST_CONTENT_INVALID'