mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-07 20:35:33 -04:00

* Enable noImplicitAny Add types to all implicit any variables Bump target to ES2020 for recent language features (optional chaining) Code cleanup Add debug configuration for vscode Remove autorun flag from jest to remove warning Bump packages to fix dependency version mismatch warning Changed @arkweid/lefthook to @evilmartians/lefthook as @arkweid/lefthook has been deprecated in favor of @evilmartians/lefthook Added concurrency groups to integrity check and build workflows. New commits to branches will cancel superseded runs on the same branch/pr Update imports to not use require syntax Use node packages (ie node:fs rather than fs) AndroidVersionCode is now a string rather than a number as it gets converted to a string when passed out of the system Reduce timeout for windows builds Remove 2020.1.17f1 from windows builds due to repeated license activation errors Update naming scheme of workflows for consistency Update build names so target platform and unity version aren't cut off by github actions UI * Add exclude to test matrix for 2022.2 on android until Unity bug is fixed --------- Co-authored-by: AndrewKahr <AndrewKahr@users.noreply.github.com>
96 lines
3.3 KiB
TypeScript
96 lines
3.3 KiB
TypeScript
import ImageTag from './image-tag';
|
|
|
|
describe('ImageTag', () => {
|
|
const testImageParameters = {
|
|
editorVersion: '2099.9.f9f9',
|
|
targetPlatform: 'Test',
|
|
builderPlatform: '',
|
|
};
|
|
|
|
const defaults = {
|
|
repository: 'unityci',
|
|
name: 'editor',
|
|
image: 'unityci/editor',
|
|
};
|
|
|
|
describe('constructor', () => {
|
|
it('can be called', () => {
|
|
expect(() => new ImageTag(testImageParameters)).not.toThrow();
|
|
});
|
|
|
|
it('accepts parameters and sets the right properties', () => {
|
|
const image = new ImageTag(testImageParameters);
|
|
|
|
expect(image.repository).toStrictEqual('unityci');
|
|
expect(image.name).toStrictEqual('editor');
|
|
expect(image.editorVersion).toStrictEqual(testImageParameters.editorVersion);
|
|
expect(image.targetPlatform).toStrictEqual(testImageParameters.targetPlatform);
|
|
expect(image.builderPlatform).toStrictEqual(testImageParameters.builderPlatform);
|
|
});
|
|
|
|
test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', (version) => {
|
|
expect(
|
|
() => new ImageTag({ editorVersion: version, targetPlatform: testImageParameters.targetPlatform }),
|
|
).not.toThrow();
|
|
});
|
|
|
|
test.each(['some version', ''])('throws for incorrect version %p', (editorVersion) => {
|
|
const { targetPlatform } = testImageParameters;
|
|
expect(() => new ImageTag({ editorVersion, targetPlatform })).toThrow();
|
|
});
|
|
|
|
test.each(['nonExisting'])('throws for unsupported target %p', (targetPlatform) => {
|
|
expect(() => new ImageTag({ targetPlatform })).toThrow();
|
|
});
|
|
});
|
|
|
|
describe('toString', () => {
|
|
it('returns the correct version', () => {
|
|
const image = new ImageTag({ editorVersion: '2099.1.1111', targetPlatform: testImageParameters.targetPlatform });
|
|
switch (process.platform) {
|
|
case 'win32':
|
|
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111-1`);
|
|
break;
|
|
case 'linux':
|
|
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111-1`);
|
|
break;
|
|
}
|
|
});
|
|
it('returns customImage if given', () => {
|
|
const image = new ImageTag({
|
|
editorVersion: '2099.1.1111',
|
|
targetPlatform: testImageParameters.targetPlatform,
|
|
customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
|
|
});
|
|
|
|
expect(image.toString()).toStrictEqual(image.customImage);
|
|
});
|
|
|
|
it('returns the specific build platform', () => {
|
|
const image = new ImageTag({ editorVersion: '2019.2.11f1', targetPlatform: 'WebGL' });
|
|
|
|
switch (process.platform) {
|
|
case 'win32':
|
|
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2019.2.11f1-webgl-1`);
|
|
break;
|
|
case 'linux':
|
|
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2019.2.11f1-webgl-1`);
|
|
break;
|
|
}
|
|
});
|
|
|
|
it('returns no specific build platform for generic targetPlatforms', () => {
|
|
const image = new ImageTag({ editorVersion: '2019.2.11f1', targetPlatform: 'NoTarget' });
|
|
|
|
switch (process.platform) {
|
|
case 'win32':
|
|
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2019.2.11f1-1`);
|
|
break;
|
|
case 'linux':
|
|
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2019.2.11f1-1`);
|
|
break;
|
|
}
|
|
});
|
|
});
|
|
});
|