import { describe, expect, test } from 'bun:test'; import { existsSync } from 'node:fs'; import { getFixturePath, getModuleTestConfig, getModuleTestSecrets, getSystemTestConfig, getSystemTestSecrets, loadTestValues, } from './fixtures'; describe('Fixture Test Utilities', () => { describe('getFixturePath', () => { test('returns absolute path to fixture', () => { const path = getFixturePath('modules/artifact-test'); expect(path).toContain('test-fixtures/modules/artifact-test'); expect(path).toMatch(/^[/\\]/); // Starts with / or \ (absolute path) }); test('handles nested paths', () => { const path = getFixturePath('modules/artifact-test/manifest.yml'); expect(path).toContain('test-fixtures/modules/artifact-test/manifest.yml'); }); test('returns path that exists', () => { const path = getFixturePath('modules/artifact-test'); expect(existsSync(path)).toBe(true); }); }); describe('loadTestValues', () => { test('loads test-values.yml', async () => { const testValues = await loadTestValues(); expect(testValues).toBeDefined(); expect(testValues).toHaveProperty('system'); expect(testValues).toHaveProperty('modules'); }); test('contains expected system configuration', async () => { const testValues = await loadTestValues(); expect(testValues.system).toBeDefined(); expect(testValues.system?.dns).toBeDefined(); }); test('contains expected module data', async () => { const testValues = await loadTestValues(); expect(testValues.modules).toBeDefined(); expect(testValues.modules?.homebridge).toBeDefined(); }); }); describe('getModuleTestConfig', () => { test('returns module configuration', async () => { const config = await getModuleTestConfig('homebridge'); expect(config).toBeDefined(); expect(config.vmid).toBe(2110); expect(config.hostname).toBe('iot'); }); test('excludes secrets from config', async () => { const config = await getModuleTestConfig('dns-external'); expect(config).toBeDefined(); expect(config.vps_ip).toBe('192.0.2.20'); expect(config.secrets).toBeUndefined(); }); test('returns empty object for non-existent module', async () => { const config = await getModuleTestConfig('non-existent-module'); expect(config).toEqual({}); }); test('handles module with no secrets', async () => { // Homebridge module has config but no secrets in test-values.yml const config = await getModuleTestConfig('homebridge'); expect(config).toBeDefined(); expect(config.hostname).toBeDefined(); }); }); describe('getModuleTestSecrets', () => { test('returns module secrets', async () => { const secrets = await getModuleTestSecrets('dns-external'); expect(secrets).toBeDefined(); expect(secrets.knot_ddns_tsig_secret).toBeTruthy(); expect(typeof secrets.knot_ddns_tsig_secret).toBe('string'); }); test('returns empty object for module with no secrets', async () => { const secrets = await getModuleTestSecrets('test-module'); expect(secrets).toEqual({}); }); test('returns empty object for non-existent module', async () => { const secrets = await getModuleTestSecrets('non-existent-module'); expect(secrets).toEqual({}); }); }); describe('getSystemTestConfig', () => { test('returns system configuration', async () => { const config = await getSystemTestConfig(); expect(config).toBeDefined(); expect(config.primary_domain).toBe('example.com'); expect(config.dns).toBeDefined(); }); test('contains nested configuration', async () => { const config = await getSystemTestConfig(); expect(config.dns).toBeDefined(); const dns = config.dns as Record; expect(dns.primary).toBe('192.168.0.1'); }); }); describe('getSystemTestSecrets', () => { test('returns system secrets (currently empty after container-services migration)', async () => { const secrets = await getSystemTestSecrets(); expect(secrets).toBeDefined(); expect(typeof secrets).toBe('object'); // Note: Proxmox credentials are now per-service, not system-wide secrets }); }); });