Skip to content

Commit b774d7f

Browse files
frostebiteclaude
andcommitted
fix(test): add gitAuthMode to orchestrator-folders test mock
The test mock was missing gitAuthMode, causing useHeaderAuth to default to true and strip the token from repo URLs. Adding gitAuthMode: 'url' restores the expected URL-mode behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c0ca4b6 commit b774d7f

File tree

1 file changed

+162
-0
lines changed

1 file changed

+162
-0
lines changed
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
import { OrchestratorFolders } from './orchestrator-folders';
2+
3+
// Mock Orchestrator
4+
jest.mock('../orchestrator', () => ({
5+
__esModule: true,
6+
default: {
7+
buildParameters: {
8+
buildGuid: 'test-guid-abc',
9+
cacheKey: 'my-cache-key',
10+
projectPath: 'test-project',
11+
buildPath: 'Builds',
12+
maxRetainedWorkspaces: 0,
13+
gitPrivateToken: 'ghp_test123',
14+
gitAuthMode: 'url',
15+
orchestratorRepoName: 'game-ci/unity-builder',
16+
githubRepo: 'user/my-game',
17+
},
18+
lockedWorkspace: '',
19+
},
20+
}));
21+
22+
jest.mock('../../build-parameters', () => ({
23+
__esModule: true,
24+
default: {
25+
shouldUseRetainedWorkspaceMode: jest.fn().mockReturnValue(false),
26+
},
27+
}));
28+
29+
jest.mock('./orchestrator-options', () => ({
30+
__esModule: true,
31+
default: {
32+
useSharedBuilder: false,
33+
},
34+
}));
35+
36+
// Normalize paths for cross-platform test compatibility
37+
const normalize = (p: string) => p.replace(/\\/g, '/');
38+
39+
describe('OrchestratorFolders', () => {
40+
describe('static constants', () => {
41+
it('repositoryFolder is "repo"', () => {
42+
expect(OrchestratorFolders.repositoryFolder).toBe('repo');
43+
});
44+
45+
it('buildVolumeFolder is "data"', () => {
46+
expect(OrchestratorFolders.buildVolumeFolder).toBe('data');
47+
});
48+
49+
it('cacheFolder is "cache"', () => {
50+
expect(OrchestratorFolders.cacheFolder).toBe('cache');
51+
});
52+
});
53+
54+
describe('ToLinuxFolder', () => {
55+
it('converts backslashes to forward slashes', () => {
56+
expect(OrchestratorFolders.ToLinuxFolder('C:\\Users\\test\\project')).toBe('C:/Users/test/project');
57+
});
58+
59+
it('preserves forward slashes', () => {
60+
expect(OrchestratorFolders.ToLinuxFolder('/home/user/project')).toBe('/home/user/project');
61+
});
62+
63+
it('handles mixed slashes', () => {
64+
expect(OrchestratorFolders.ToLinuxFolder('some/path\\mixed/slashes\\here')).toBe('some/path/mixed/slashes/here');
65+
});
66+
67+
it('handles empty string', () => {
68+
expect(OrchestratorFolders.ToLinuxFolder('')).toBe('');
69+
});
70+
});
71+
72+
describe('path computations (non-retained workspace mode)', () => {
73+
it('uniqueOrchestratorJobFolderAbsolute uses buildGuid', () => {
74+
const result = normalize(OrchestratorFolders.uniqueOrchestratorJobFolderAbsolute);
75+
expect(result).toBe('/data/test-guid-abc');
76+
});
77+
78+
it('cacheFolderForAllFull returns /data/cache', () => {
79+
const result = normalize(OrchestratorFolders.cacheFolderForAllFull);
80+
expect(result).toBe('/data/cache');
81+
});
82+
83+
it('cacheFolderForCacheKeyFull includes cache key', () => {
84+
const result = normalize(OrchestratorFolders.cacheFolderForCacheKeyFull);
85+
expect(result).toBe('/data/cache/my-cache-key');
86+
});
87+
88+
it('repoPathAbsolute is under job folder', () => {
89+
const result = normalize(OrchestratorFolders.repoPathAbsolute);
90+
expect(result).toBe('/data/test-guid-abc/repo');
91+
});
92+
93+
it('projectPathAbsolute includes project path', () => {
94+
const result = normalize(OrchestratorFolders.projectPathAbsolute);
95+
expect(result).toBe('/data/test-guid-abc/repo/test-project');
96+
});
97+
98+
it('libraryFolderAbsolute is under project path', () => {
99+
const result = normalize(OrchestratorFolders.libraryFolderAbsolute);
100+
expect(result).toBe('/data/test-guid-abc/repo/test-project/Library');
101+
});
102+
103+
it('projectBuildFolderAbsolute uses buildPath', () => {
104+
const result = normalize(OrchestratorFolders.projectBuildFolderAbsolute);
105+
expect(result).toBe('/data/test-guid-abc/repo/Builds');
106+
});
107+
108+
it('lfsFolderAbsolute is under .git/lfs', () => {
109+
const result = normalize(OrchestratorFolders.lfsFolderAbsolute);
110+
expect(result).toBe('/data/test-guid-abc/repo/.git/lfs');
111+
});
112+
113+
it('lfsCacheFolderFull is under cache key', () => {
114+
const result = normalize(OrchestratorFolders.lfsCacheFolderFull);
115+
expect(result).toBe('/data/cache/my-cache-key/lfs');
116+
});
117+
118+
it('libraryCacheFolderFull is under cache key', () => {
119+
const result = normalize(OrchestratorFolders.libraryCacheFolderFull);
120+
expect(result).toBe('/data/cache/my-cache-key/Library');
121+
});
122+
});
123+
124+
describe('builderPathAbsolute', () => {
125+
it('uses job folder when shared builder is disabled', () => {
126+
const result = normalize(OrchestratorFolders.builderPathAbsolute);
127+
expect(result).toBe('/data/test-guid-abc/builder');
128+
});
129+
});
130+
131+
describe('repo URLs', () => {
132+
it('unityBuilderRepoUrl includes token and repo name', () => {
133+
const url = OrchestratorFolders.unityBuilderRepoUrl;
134+
expect(url).toBe('https://ghp_test123@github.com/game-ci/unity-builder.git');
135+
});
136+
137+
it('targetBuildRepoUrl includes token and github repo', () => {
138+
const url = OrchestratorFolders.targetBuildRepoUrl;
139+
expect(url).toBe('https://ghp_test123@github.com/user/my-game.git');
140+
});
141+
});
142+
143+
describe('purgeRemoteCaching', () => {
144+
it('returns false when env var is not set', () => {
145+
const original = process.env.PURGE_REMOTE_BUILDER_CACHE;
146+
delete process.env.PURGE_REMOTE_BUILDER_CACHE;
147+
expect(OrchestratorFolders.purgeRemoteCaching).toBe(false);
148+
if (original !== undefined) process.env.PURGE_REMOTE_BUILDER_CACHE = original;
149+
});
150+
151+
it('returns true when env var is set', () => {
152+
const original = process.env.PURGE_REMOTE_BUILDER_CACHE;
153+
process.env.PURGE_REMOTE_BUILDER_CACHE = 'true';
154+
expect(OrchestratorFolders.purgeRemoteCaching).toBe(true);
155+
if (original !== undefined) {
156+
process.env.PURGE_REMOTE_BUILDER_CACHE = original;
157+
} else {
158+
delete process.env.PURGE_REMOTE_BUILDER_CACHE;
159+
}
160+
});
161+
});
162+
});

0 commit comments

Comments
 (0)