mirror of
https://github.com/game-ci/unity-test-runner.git
synced 2026-01-29 06:20:07 +08:00
* (should fail) add jq install to docker image * (might fail) remove rm rf call * move things around to try to fix test * Revert "(might fail) remove rm rf call" This reverts commit22f74ebca7. * remove silent setting from docker test * Fix failing test's Docker image * Add new input and basic test * Add test package; start using jq cli * Use test package in test workflow * Create temporary Unity Project and run tests * Test removing jq install from Dockerfile * Revert "Test removing jq install from Dockerfile" This reverts commit6aa7a6f443. * Remove mkdir call * remove duplicate command * add packageMode option back in * build changes * check for apt-get before installing jq * change apt-get version check message * spelling and documentation fixes * add working example unity package with tests * add temp pwd call to help figure out absolute pathing * fix workflow package location * add jq to add package to temp project packages * try fixing jq calls * clean up jq calls, fix variable expansion * try renaming jq args * try using different arg syntax for jq * try wrapping args in parentheses * try using double quotes only * try changing up quoting * try properly using string interpolation * try removing colon * add string interpolation to key * omit double quotes from jq call to retrieve package name * clean up logging * add rest of workflow tests * Revert "add rest of workflow tests" This reverts commitc0bb008b2c. * add play mode test without cache * add package mode all mode workflow step * add consecutive ppackage mode workflow step * add package mode "like in the readme" test * fix workflow syntax error * try to fix syntax error again * use correct folder * *hopefully actually* use correct package path * try adding caching to "readme" test * remove caching/mentions of caching from package mode tests * fix artifacts paths * fix artifacts pathing and names * fix combined artifacts for package mode * clean up documentation and exit code * clarify allowed docker images for packageMode * update README to mention Unity packages * move package name validation to TS part of action * improve logging for temp project creation failure * make husky hook executable * add error for missing tests folder * update docs to reflect unsupported packages * remove jq install * Revert "remove jq install" This reverts commitbd35ac8f6f. * TEMP log image in use * Revert "TEMP log image in use" This reverts commit95722dcab4. * Revert "Revert "remove jq install"" This reverts commite3bac048b1. * TEMP list installed packages * Revert "TEMP list installed packages" This reverts commitdb9c07da38. * TEMP log project's manifest * add code coverage package to generated project * remove temp project manifest log * add coverage to package mode tests * update name of package coverage steps * add codecoverage dependency to test package * Revert "add codecoverage dependency to test package" This reverts commit4b2c03069d. * add assembly filters for coverage * TEMP console log project folder * Revert "TEMP console log project folder" This reverts commit411ec51817. * add logic to copy package to folder without activation file * fix false positive activation file detection * fix improper bash "if" formatting * TEMP remove conditional for package copying * Revert "TEMP remove conditional for package copying" This reverts commit4f12d83889. * Revert "fix improper bash "if" formatting" This reverts commitacb975bcea. * Revert "fix false positive activation file detection" This reverts commit580c9c14a0. * Revert "add logic to copy package to folder without activation file" This reverts commitb20d994b5d. * run yarn build * move package mode check lower in the file * throw error if unity version is auto in package mode * fix unity version error wording * try deleting activate license file * try logging hidden package files * try deleting all non-package files * fix license activation files deletion * scrap file removals and print dir permissions * log permissions for package folder * Add packageMode inputs to main * fix fs mocks and run yarn build * fix documentation and add error message for missing jq * add clarification on package mode caveats * fix line endings problem (?) * Revert "fix line endings problem (?)" This reverts commit1cba302bc4. * Revert "add clarification on package mode caveats" This reverts commitfb62d36ba1. * Revert "fix documentation and add error message for missing jq" This reverts commit0df3ab6b88. * Redo the input docs fixes * Redo the jq presence test * update readme to indicate package mode caveats * fix wording on coverageOptions * one more wording fix on coverageOptions * move sample package to example.com domain --------- Co-authored-by: Aaron Trudeau <120415438+trudeaua-vividream-software@users.noreply.github.com>
116 lines
3.9 KiB
TypeScript
116 lines
3.9 KiB
TypeScript
import Input from './input';
|
|
import fs from 'fs';
|
|
|
|
jest.mock('./unity-version-parser');
|
|
|
|
const mockedFsExistsSync = jest.spyOn(fs, 'existsSync');
|
|
const mockedFsReadFileSync = jest.spyOn(fs, 'readFileSync');
|
|
|
|
describe('Input', () => {
|
|
describe('getFromUser', () => {
|
|
it('does not throw', () => {
|
|
expect(() => Input.getFromUser()).not.toThrow();
|
|
});
|
|
|
|
it('returns an object', () => {
|
|
expect(typeof Input.getFromUser()).toStrictEqual('object');
|
|
});
|
|
});
|
|
|
|
describe('isValidFolderName', () => {
|
|
test.each([
|
|
'.',
|
|
'./',
|
|
'folder',
|
|
'trailing/',
|
|
'.hidden',
|
|
'.hidden/sub',
|
|
'.hidden/trailing/',
|
|
'./.hidden-sub',
|
|
'hyphen-folder',
|
|
'under_score',
|
|
])('returns true for %s', folderName => {
|
|
expect(Input.isValidFolderName(folderName)).toStrictEqual(true);
|
|
});
|
|
|
|
test.each(['..', '../'])('returns false for %s', folderName => {
|
|
expect(Input.isValidFolderName(folderName)).toStrictEqual(false);
|
|
});
|
|
});
|
|
|
|
describe('getPackageNameFromPackageJson', () => {
|
|
it('throws error if package.json cannot be found at the given project path', () => {
|
|
mockedFsExistsSync.mockReturnValue(false);
|
|
|
|
expect(() => Input.getPackageNameFromPackageJson('some/path')).toThrow(
|
|
'Invalid projectPath - Cannot find package.json at some/path/package.json',
|
|
);
|
|
});
|
|
|
|
it('throws error if package.json contents cannot be parsed', () => {
|
|
mockedFsExistsSync.mockReturnValue(true);
|
|
mockedFsReadFileSync.mockReturnValue(Buffer.from('DefinitelyNotJSON'));
|
|
|
|
expect(() => Input.getPackageNameFromPackageJson('some/path')).toThrow(
|
|
/Unable to parse package.json contents as JSON/,
|
|
);
|
|
});
|
|
|
|
it('throws error if name field in package.json is not present', () => {
|
|
mockedFsExistsSync.mockReturnValue(true);
|
|
mockedFsReadFileSync.mockReturnValue(
|
|
Buffer.from(JSON.stringify({ notName: 'some-package', alsoNotName: 'some-package' })),
|
|
);
|
|
|
|
expect(() => Input.getPackageNameFromPackageJson('some/path')).toThrow(
|
|
'Unable to parse package name from package.json - package name should be string, but was undefined',
|
|
);
|
|
});
|
|
|
|
it('throws error if name field in package.json is present but not a string', () => {
|
|
mockedFsExistsSync.mockReturnValue(true);
|
|
mockedFsReadFileSync.mockReturnValue(
|
|
Buffer.from(JSON.stringify({ name: 3, notName: 'some-package' })),
|
|
);
|
|
|
|
expect(() => Input.getPackageNameFromPackageJson('some/path')).toThrow(
|
|
'Unable to parse package name from package.json - package name should be string, but was number',
|
|
);
|
|
});
|
|
|
|
it('throws error if name field in package.json is present but empty', () => {
|
|
mockedFsExistsSync.mockReturnValue(true);
|
|
mockedFsReadFileSync.mockReturnValue(Buffer.from(JSON.stringify({ name: '', notName: 3 })));
|
|
|
|
expect(() => Input.getPackageNameFromPackageJson('some/path')).toThrow(
|
|
'Package name from package.json is a string, but is empty',
|
|
);
|
|
});
|
|
|
|
it('returns the name field in package.json if it is present as a non-empty string', () => {
|
|
mockedFsExistsSync.mockReturnValue(true);
|
|
mockedFsReadFileSync.mockReturnValue(
|
|
Buffer.from(JSON.stringify({ name: 'some-package', notName: 'not-what-we-want' })),
|
|
);
|
|
|
|
expect(Input.getPackageNameFromPackageJson('some/path')).toStrictEqual('some-package');
|
|
});
|
|
});
|
|
|
|
describe('verifyTestsFolderIsPresent', () => {
|
|
it('throws error if tests folder is not present', () => {
|
|
mockedFsExistsSync.mockReturnValue(false);
|
|
|
|
expect(() => Input.verifyTestsFolderIsPresent('some/path')).toThrow(
|
|
'Invalid projectPath - Cannot find package tests folder at some/path/Tests',
|
|
);
|
|
});
|
|
|
|
it('does not throw if tests folder is present', () => {
|
|
mockedFsExistsSync.mockReturnValue(true);
|
|
|
|
expect(() => Input.verifyTestsFolderIsPresent('some/path')).not.toThrow();
|
|
});
|
|
});
|
|
});
|