mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-09-10 09:35:39 +00:00
1bc16efe8f
- Implemented logic to reissue incomplete or expired signed Support Agent profiles during rebuilds, preventing operators from getting stuck in retry loops. - Updated `build.sh` to handle the absence of `branding.pub` more gracefully, ensuring it doesn't fail on fresh workspaces. - Refactored branding functions to utilize a dedicated support profile service, improving code organization and maintainability. - Added tests to verify the correct behavior of version injection and support profile validity checks.
51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
const fs = require('fs');
|
|
const os = require('os');
|
|
const path = require('path');
|
|
|
|
describe('agentBuildWorker product version injection', () => {
|
|
let rootDir;
|
|
|
|
beforeEach(() => {
|
|
rootDir = fs.mkdtempSync(path.join(os.tmpdir(), 'bd-agent-version-'));
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(rootDir, { recursive: true, force: true });
|
|
});
|
|
|
|
test('reads root VERSION and injects it into the copied Support Agent source', async () => {
|
|
const workspace = path.join(rootDir, 'workspace');
|
|
fs.mkdirSync(workspace, { recursive: true });
|
|
fs.writeFileSync(path.join(rootDir, 'VERSION'), '7.6.5\n');
|
|
fs.writeFileSync(
|
|
path.join(workspace, 'main.go'),
|
|
'package main\n\nvar version = "0.1.0"\n'
|
|
);
|
|
|
|
const worker = require('../services/agentBuildWorker');
|
|
const version = await worker._internals.injectSupportAgentVersion(workspace, { rootDir });
|
|
|
|
expect(version).toBe('7.6.5');
|
|
expect(worker._internals.getSupportAgentBuildVersion({ rootDir })).toBe('7.6.5');
|
|
expect(fs.readFileSync(path.join(workspace, 'main.go'), 'utf8'))
|
|
.toContain('var version = "7.6.5"');
|
|
});
|
|
|
|
test('inject succeeds when main.go already has the target version', async () => {
|
|
const workspace = path.join(rootDir, 'workspace');
|
|
fs.mkdirSync(workspace, { recursive: true });
|
|
fs.writeFileSync(
|
|
path.join(workspace, 'main.go'),
|
|
'package main\n\nvar version = "0.1.0"\n'
|
|
);
|
|
|
|
const worker = require('../services/agentBuildWorker');
|
|
const version = await worker._internals.injectSupportAgentVersion(workspace, {
|
|
version: '0.1.0',
|
|
});
|
|
expect(version).toBe('0.1.0');
|
|
});
|
|
});
|