PSA/ee/appliance/operator/tests/runtime-paths.test.mjs
Hermes 284313f908
Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Initial import of AlgaPSA codebase from PSA server
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz

Source: /opt/alga-psa on psa.joliet.tech
2026-06-22 16:12:17 -05:00

61 lines
2.7 KiB
JavaScript

import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import test from 'node:test';
import { discoverEnvironment, selectDiscoveredSite } from '../lib/environment.mjs';
import { resolveConfigBase, resolveRuntimePaths } from '../lib/runtime-paths.mjs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
test('T006: resolves repo runtime paths from repository layout', () => {
const fixtureRoot = path.resolve(__dirname, 'fixtures/runtime-repo');
const nestedCwd = path.join(fixtureRoot, 'ee/appliance/scripts');
const runtime = resolveRuntimePaths({ cwd: nestedCwd });
assert.equal(runtime.runtimeMode, 'repo');
assert.equal(runtime.repoRoot, fixtureRoot);
assert.equal(runtime.supportBundleScript, path.join(fixtureRoot, 'ee/appliance/scripts/collect-support-bundle.sh'));
assert.equal(runtime.resetScript, path.join(fixtureRoot, 'ee/appliance/scripts/reset-appliance-data.sh'));
});
test('T006: resolves standalone asset-root runtime paths', () => {
const fixtureRoot = path.resolve(__dirname, 'fixtures/runtime-bundle');
const runtime = resolveRuntimePaths({ assetRoot: fixtureRoot });
assert.equal(runtime.runtimeMode, 'asset-root');
assert.equal(runtime.assetRoot, fixtureRoot);
assert.equal(runtime.supportBundleScript, path.join(fixtureRoot, 'scripts/collect-support-bundle.sh'));
assert.equal(runtime.resetScript, path.join(fixtureRoot, 'scripts/reset-appliance-data.sh'));
});
test('resolveConfigBase defaults to a product-owned appliance config home', () => {
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'appliance-operator-home-'));
assert.equal(resolveConfigBase(home), path.join(home, '.alga-psa-appliance'));
});
test('environment discovery defers site selection in TUI mode when multiple sites exist', () => {
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'appliance-operator-home-'));
for (const siteId of ['site-a', 'site-b']) {
const siteDir = path.join(home, '.alga-psa-appliance', siteId);
fs.mkdirSync(siteDir, { recursive: true });
fs.writeFileSync(path.join(siteDir, 'kubeconfig'), 'fake');
fs.writeFileSync(path.join(siteDir, 'talosconfig'), 'fake');
}
const env = discoverEnvironment({
homeDir: home,
cwd: path.resolve(__dirname, 'fixtures/runtime-repo'),
allowAmbiguousSiteSelection: true,
});
assert.equal(env.siteSelectionRequired, true);
assert.equal(env.site, null);
const selected = selectDiscoveredSite(env, 'site-b');
assert.equal(selected.site.siteId, 'site-b');
assert.equal(selected.paths.kubeconfig, path.join(home, '.alga-psa-appliance', 'site-b', 'kubeconfig'));
});