mirror of
https://github.com/game-ci/unity-builder.git
synced 2026-06-13 01:13:54 -07:00
17a0ea3776
Adds 64 new mock-based unit tests covering orchestrator services that previously had zero test coverage: - TaskParameterSerializer: env var format conversion, round-trip, uniqBy deduplication, blocked params, default secrets - FollowLogStreamService: build output message parsing — end of transmission, build success/failure detection, error accumulation, Library rebuild detection - OrchestratorNamespace (guid): GUID generation format, platform name normalization, nanoid uniqueness - OrchestratorFolders: path computation for all folder getters, ToLinuxFolder conversion, repo URL generation, purge flag detection All tests are pure mock-based and run without any external infrastructure (no LocalStack, K8s, Docker, or AWS). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
54 lines
2.0 KiB
TypeScript
54 lines
2.0 KiB
TypeScript
import OrchestratorNamespace from './orchestrator-guid';
|
|
|
|
describe('OrchestratorNamespace', () => {
|
|
describe('generateGuid', () => {
|
|
it('generates a guid with correct format', () => {
|
|
const guid = OrchestratorNamespace.generateGuid('42', 'StandaloneLinux64');
|
|
// Format: {runNumber}-{platform}-{nanoid4}
|
|
expect(guid).toMatch(/^42-linux64-[a-z0-9]{4}$/);
|
|
});
|
|
|
|
it('strips "standalone" prefix from platform (case-insensitive)', () => {
|
|
const guid = OrchestratorNamespace.generateGuid('1', 'StandaloneWindows64');
|
|
expect(guid).toMatch(/^1-windows64-[a-z0-9]{4}$/);
|
|
});
|
|
|
|
it('lowercases platform name', () => {
|
|
const guid = OrchestratorNamespace.generateGuid('5', 'Android');
|
|
expect(guid).toMatch(/^5-android-[a-z0-9]{4}$/);
|
|
});
|
|
|
|
it('handles numeric run number', () => {
|
|
const guid = OrchestratorNamespace.generateGuid(100, 'iOS');
|
|
expect(guid).toMatch(/^100-ios-[a-z0-9]{4}$/);
|
|
});
|
|
|
|
it('generates unique guids on repeated calls', () => {
|
|
const guids = new Set<string>();
|
|
for (let i = 0; i < 20; i++) {
|
|
guids.add(OrchestratorNamespace.generateGuid('1', 'StandaloneLinux64'));
|
|
}
|
|
// With 4 alphanumeric chars (36^4 = ~1.7M possibilities), 20 calls should almost certainly be unique
|
|
expect(guids.size).toBeGreaterThan(1);
|
|
});
|
|
|
|
it('handles StandaloneOSX platform', () => {
|
|
const guid = OrchestratorNamespace.generateGuid('7', 'StandaloneOSX');
|
|
expect(guid).toMatch(/^7-osx-[a-z0-9]{4}$/);
|
|
});
|
|
|
|
it('handles WebGL platform (no standalone prefix)', () => {
|
|
const guid = OrchestratorNamespace.generateGuid('3', 'WebGL');
|
|
expect(guid).toMatch(/^3-webgl-[a-z0-9]{4}$/);
|
|
});
|
|
|
|
it('uses only lowercase alphanumeric characters in nanoid portion', () => {
|
|
for (let i = 0; i < 10; i++) {
|
|
const guid = OrchestratorNamespace.generateGuid('1', 'test');
|
|
const nanoidPart = guid.split('-').pop()!;
|
|
expect(nanoidPart).toMatch(/^[0-9a-z]{4}$/);
|
|
}
|
|
});
|
|
});
|
|
});
|