|
5 | 5 | SysEnvironment, |
6 | 6 | SysDatabaseCredential, |
7 | 7 | SysEnvironmentMember, |
| 8 | + SysPackage, |
| 9 | + SysPackageVersion, |
| 10 | + SysPackageInstallation, |
8 | 11 | } from './index'; |
9 | 12 |
|
10 | 13 | describe('control-plane environment objects', () => { |
@@ -51,3 +54,68 @@ describe('control-plane environment objects', () => { |
51 | 54 | expect(SysEnvironmentMember.isSystem).toBe(true); |
52 | 55 | }); |
53 | 56 | }); |
| 57 | + |
| 58 | +describe('control-plane package objects (ADR-0003)', () => { |
| 59 | + it('registers sys_package and sys_package_version with correct namespaced names', () => { |
| 60 | + expect(`${SysPackage.namespace}_${SysPackage.name}`).toBe('sys_package'); |
| 61 | + expect(`${SysPackageVersion.namespace}_${SysPackageVersion.name}`).toBe('sys_package_version'); |
| 62 | + expect(`${SysPackageInstallation.namespace}_${SysPackageInstallation.name}`).toBe('sys_package_installation'); |
| 63 | + }); |
| 64 | + |
| 65 | + it('marks all package objects as system objects', () => { |
| 66 | + expect(SysPackage.isSystem).toBe(true); |
| 67 | + expect(SysPackageVersion.isSystem).toBe(true); |
| 68 | + expect(SysPackageInstallation.isSystem).toBe(true); |
| 69 | + }); |
| 70 | + |
| 71 | + it('sys_package has UNIQUE manifest_id index', () => { |
| 72 | + const idx = SysPackage.indexes ?? []; |
| 73 | + expect( |
| 74 | + idx.some((i: any) => i.unique && i.fields.join(',') === 'manifest_id'), |
| 75 | + ).toBe(true); |
| 76 | + }); |
| 77 | + |
| 78 | + it('sys_package_version has UNIQUE (package_id, version) index', () => { |
| 79 | + const idx = SysPackageVersion.indexes ?? []; |
| 80 | + expect( |
| 81 | + idx.some((i: any) => i.unique && i.fields.join(',') === 'package_id,version'), |
| 82 | + ).toBe(true); |
| 83 | + }); |
| 84 | + |
| 85 | + it('sys_package_installation has UNIQUE (environment_id, package_id) index', () => { |
| 86 | + const idx = SysPackageInstallation.indexes ?? []; |
| 87 | + expect( |
| 88 | + idx.some((i: any) => i.unique && i.fields.join(',') === 'environment_id,package_id'), |
| 89 | + ).toBe(true); |
| 90 | + }); |
| 91 | + |
| 92 | + it('sys_package_installation has package_version_id field (not a version string)', () => { |
| 93 | + expect(SysPackageInstallation.fields).toHaveProperty('package_version_id'); |
| 94 | + expect(SysPackageInstallation.fields).not.toHaveProperty('upgrade_history'); |
| 95 | + }); |
| 96 | + |
| 97 | + it('sys_package_installation has package_version_id index', () => { |
| 98 | + const idx = SysPackageInstallation.indexes ?? []; |
| 99 | + expect( |
| 100 | + idx.some((i: any) => i.fields.join(',') === 'package_version_id'), |
| 101 | + ).toBe(true); |
| 102 | + }); |
| 103 | + |
| 104 | + it('gives every field on sys_package a .description', () => { |
| 105 | + for (const [name, field] of Object.entries(SysPackage.fields)) { |
| 106 | + expect((field as any).description, `sys_package.${name} missing description`).toBeTruthy(); |
| 107 | + } |
| 108 | + }); |
| 109 | + |
| 110 | + it('gives every field on sys_package_version a .description', () => { |
| 111 | + for (const [name, field] of Object.entries(SysPackageVersion.fields)) { |
| 112 | + expect((field as any).description, `sys_package_version.${name} missing description`).toBeTruthy(); |
| 113 | + } |
| 114 | + }); |
| 115 | + |
| 116 | + it('gives every field on sys_package_installation a .description', () => { |
| 117 | + for (const [name, field] of Object.entries(SysPackageInstallation.fields)) { |
| 118 | + expect((field as any).description, `sys_package_installation.${name} missing description`).toBeTruthy(); |
| 119 | + } |
| 120 | + }); |
| 121 | +}); |
0 commit comments