Switch to version 1 images (#374)

* feat: upgrade to images of version 1 (rolling tag)

* chore: indicate what needs to move out of the input class
This commit is contained in:
Webber Takken
2022-04-03 17:59:14 +02:00
committed by GitHub
parent 1bc7130fea
commit 441be81543
17 changed files with 175 additions and 139 deletions

View File

@@ -2,10 +2,8 @@ import ImageTag from './image-tag';
describe('ImageTag', () => {
const some = {
repository: 'test1',
name: 'test2',
version: '2099.9.f9f9',
platform: 'Test',
editorVersion: '2099.9.f9f9',
targetPlatform: 'Test',
builderPlatform: '',
};
@@ -17,50 +15,51 @@ describe('ImageTag', () => {
describe('constructor', () => {
it('can be called', () => {
const { platform } = some;
expect(() => new ImageTag({ platform })).not.toThrow();
const { targetPlatform } = some;
expect(() => new ImageTag({ targetPlatform })).not.toThrow();
});
it('accepts parameters and sets the right properties', () => {
const image = new ImageTag(some);
expect(image.repository).toStrictEqual(some.repository);
expect(image.name).toStrictEqual(some.name);
expect(image.version).toStrictEqual(some.version);
expect(image.platform).toStrictEqual(some.platform);
expect(image.repository).toStrictEqual('unityci');
expect(image.name).toStrictEqual('editor');
expect(image.editorVersion).toStrictEqual(some.editorVersion);
expect(image.targetPlatform).toStrictEqual(some.targetPlatform);
expect(image.builderPlatform).toStrictEqual(some.builderPlatform);
});
test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', (version) => {
expect(() => new ImageTag({ version, platform: some.platform })).not.toThrow();
expect(() => new ImageTag({ editorVersion: version, targetPlatform: some.targetPlatform })).not.toThrow();
});
test.each(['some version', '', 1])('throws for incorrect versions %p', (version) => {
const { platform } = some;
expect(() => new ImageTag({ version, platform })).toThrow();
test.each(['some version', ''])('throws for incorrect version %p', (editorVersion) => {
const { targetPlatform } = some;
expect(() => new ImageTag({ editorVersion, targetPlatform })).toThrow();
});
test.each([undefined, 'nonExisting'])('throws for unsupported target %p', (platform) => {
expect(() => new ImageTag({ platform })).toThrow();
test.each([undefined, 'nonExisting'])('throws for unsupported target %p', (targetPlatform) => {
expect(() => new ImageTag({ targetPlatform })).toThrow();
});
});
describe('toString', () => {
it('returns the correct version', () => {
const image = new ImageTag({ version: '2099.1.1111', platform: some.platform });
const image = new ImageTag({ editorVersion: '2099.1.1111', targetPlatform: some.targetPlatform });
switch (process.platform) {
case 'win32':
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111-0`);
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111-1`);
break;
case 'linux':
expect(image.toString()).toStrictEqual(`${defaults.image}:2099.1.1111-0`);
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111-1`);
break;
}
});
it('returns customImage if given', () => {
const image = new ImageTag({
version: '2099.1.1111',
platform: some.platform,
editorVersion: '2099.1.1111',
targetPlatform: some.targetPlatform,
customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
});
@@ -68,27 +67,27 @@ describe('ImageTag', () => {
});
it('returns the specific build platform', () => {
const image = new ImageTag({ version: '2019.2.11f1', platform: 'WebGL' });
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-0`);
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2019.2.11f1-webgl-1`);
break;
case 'linux':
expect(image.toString()).toStrictEqual(`${defaults.image}:2019.2.11f1-webgl-0`);
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({ platform: 'NoTarget' });
const image = new ImageTag({ targetPlatform: 'NoTarget' });
switch (process.platform) {
case 'win32':
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2019.2.11f1-0`);
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2019.2.11f1-1`);
break;
case 'linux':
expect(image.toString()).toStrictEqual(`${defaults.image}:2019.2.11f1-0`);
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2019.2.11f1-1`);
break;
}
});