Files
unity-builder/src/model/orchestrator/tests/providers/provider-url-parser.test.ts
Frostebite 9d475434d3 Rename Cloud Runner to Orchestrator (#775)
* Rename "Cloud Runner" to "Orchestrator" across entire codebase

Breaking change: All CloudRunner classes, options, environment variables,
and action.yml inputs have been renamed to Orchestrator equivalents.

- Renamed src/model/cloud-runner/ directory to src/model/orchestrator/
- Renamed all cloud-runner-* files to orchestrator-*
- Renamed all CloudRunner* classes to Orchestrator* (15+ classes)
- Renamed all cloudRunner* properties to orchestrator* equivalents
- Renamed CLOUD_RUNNER_* env vars to ORCHESTRATOR_*
- Updated action.yml [CloudRunner] markers to [Orchestrator]
- Updated workflow files and package.json test scripts
- Updated all runtime strings (cache paths, log messages, branch refs)
- Rebuilt dist/index.js

No backward compatibility layer is provided.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* Remove tracked log/temp files and add to .gitignore

Remove $LOG_FILE and temp/job-log.txt debug artifacts that should
not be in the repository.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-04 21:53:47 +00:00

186 lines
5.4 KiB
TypeScript

import { parseProviderSource, generateCacheKey, isGitHubSource } from '../../providers/provider-url-parser';
describe('provider-url-parser', () => {
describe('parseProviderSource', () => {
it('parses HTTPS GitHub URLs correctly', () => {
const result = parseProviderSource('https://github.com/user/repo');
expect(result).toEqual({
type: 'github',
owner: 'user',
repo: 'repo',
branch: 'main',
path: '',
url: 'https://github.com/user/repo',
});
});
it('parses HTTPS GitHub URLs with branch', () => {
const result = parseProviderSource('https://github.com/user/repo/tree/develop');
expect(result).toEqual({
type: 'github',
owner: 'user',
repo: 'repo',
branch: 'develop',
path: '',
url: 'https://github.com/user/repo',
});
});
it('parses HTTPS GitHub URLs with path', () => {
const result = parseProviderSource('https://github.com/user/repo/tree/main/src/providers');
expect(result).toEqual({
type: 'github',
owner: 'user',
repo: 'repo',
branch: 'main',
path: 'src/providers',
url: 'https://github.com/user/repo',
});
});
it('parses GitHub URLs with .git extension', () => {
const result = parseProviderSource('https://github.com/user/repo.git');
expect(result).toEqual({
type: 'github',
owner: 'user',
repo: 'repo',
branch: 'main',
path: '',
url: 'https://github.com/user/repo',
});
});
it('parses SSH GitHub URLs', () => {
const result = parseProviderSource('git@github.com:user/repo.git');
expect(result).toEqual({
type: 'github',
owner: 'user',
repo: 'repo',
branch: 'main',
path: '',
url: 'https://github.com/user/repo',
});
});
it('parses shorthand GitHub references', () => {
const result = parseProviderSource('user/repo');
expect(result).toEqual({
type: 'github',
owner: 'user',
repo: 'repo',
branch: 'main',
path: '',
url: 'https://github.com/user/repo',
});
});
it('parses shorthand GitHub references with branch', () => {
const result = parseProviderSource('user/repo@develop');
expect(result).toEqual({
type: 'github',
owner: 'user',
repo: 'repo',
branch: 'develop',
path: '',
url: 'https://github.com/user/repo',
});
});
it('parses shorthand GitHub references with path', () => {
const result = parseProviderSource('user/repo@main/src/providers');
expect(result).toEqual({
type: 'github',
owner: 'user',
repo: 'repo',
branch: 'main',
path: 'src/providers',
url: 'https://github.com/user/repo',
});
});
it('parses local relative paths', () => {
const result = parseProviderSource('./my-provider');
expect(result).toEqual({
type: 'local',
path: './my-provider',
});
});
it('parses local absolute paths', () => {
const result = parseProviderSource('/path/to/provider');
expect(result).toEqual({
type: 'local',
path: '/path/to/provider',
});
});
it('parses Windows paths', () => {
const result = parseProviderSource('C:\\path\\to\\provider');
expect(result).toEqual({
type: 'local',
path: 'C:\\path\\to\\provider',
});
});
it('parses NPM package names', () => {
const result = parseProviderSource('my-provider-package');
expect(result).toEqual({
type: 'npm',
packageName: 'my-provider-package',
});
});
it('parses scoped NPM package names', () => {
const result = parseProviderSource('@scope/my-provider');
expect(result).toEqual({
type: 'npm',
packageName: '@scope/my-provider',
});
});
});
describe('generateCacheKey', () => {
it('generates valid cache keys for GitHub URLs', () => {
const urlInfo = {
type: 'github' as const,
owner: 'user',
repo: 'my-repo',
branch: 'develop',
url: 'https://github.com/user/my-repo',
};
const key = generateCacheKey(urlInfo);
expect(key).toBe('github_user_my-repo_develop');
});
it('handles special characters in cache keys', () => {
const urlInfo = {
type: 'github' as const,
owner: 'user-name',
repo: 'my.repo',
branch: 'feature/branch',
url: 'https://github.com/user-name/my.repo',
};
const key = generateCacheKey(urlInfo);
expect(key).toBe('github_user-name_my_repo_feature_branch');
});
});
describe('isGitHubSource', () => {
it('identifies GitHub URLs correctly', () => {
expect(isGitHubSource('https://github.com/user/repo')).toBe(true);
expect(isGitHubSource('git@github.com:user/repo.git')).toBe(true);
expect(isGitHubSource('user/repo')).toBe(true);
expect(isGitHubSource('user/repo@develop')).toBe(true);
});
it('identifies non-GitHub sources correctly', () => {
expect(isGitHubSource('./local-provider')).toBe(false);
expect(isGitHubSource('/absolute/path')).toBe(false);
expect(isGitHubSource('npm-package')).toBe(false);
expect(isGitHubSource('@scope/package')).toBe(false);
});
});
});