mirror of
				https://kkgithub.com/actions/setup-node.git
				synced 2025-10-31 10:41:57 +08:00 
			
		
		
		
	Logic remastered to not force check-latest
This commit is contained in:
		| @ -399,6 +399,7 @@ describe('setup-node', () => { | ||||
|       expect(logSpy).not.toHaveBeenCalledWith( | ||||
|         'Attempt to resolve the latest version from manifest...' | ||||
|       ); | ||||
|       expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached, getting manifest from actions/node-versions@main') | ||||
|     }); | ||||
|  | ||||
|     it('check latest version and resolve it from local cache', async () => { | ||||
| @ -419,6 +420,7 @@ describe('setup-node', () => { | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         'Attempt to resolve the latest version from manifest...' | ||||
|       ); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith('No manifest cached, getting manifest from actions/node-versions@main') | ||||
|       expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'"); | ||||
|       expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); | ||||
|     }); | ||||
| @ -443,6 +445,7 @@ describe('setup-node', () => { | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         'Attempt to resolve the latest version from manifest...' | ||||
|       ); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith('No manifest cached, getting manifest from actions/node-versions@main') | ||||
|       expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'"); | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         `Acquiring 12.16.2 - ${os.arch} from ${expectedUrl}` | ||||
| @ -479,6 +482,7 @@ describe('setup-node', () => { | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         'Attempt to resolve the latest version from manifest...' | ||||
|       ); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith('No manifest cached, getting manifest from actions/node-versions@main') | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         `Failed to resolve version ${versionSpec} from manifest` | ||||
|       ); | ||||
| @ -522,6 +526,7 @@ describe('setup-node', () => { | ||||
|       ); | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         'Unable to resolve version from manifest...' | ||||
|         // 'Unable to get manifest...' | ||||
|       ); | ||||
|       expect(logSpy).toHaveBeenCalledWith( | ||||
|         `Failed to resolve version ${versionSpec} from manifest` | ||||
| @ -549,11 +554,11 @@ describe('setup-node', () => { | ||||
|       await main.run(); | ||||
|  | ||||
|       // assert | ||||
|       expect(logSpy).toHaveBeenCalledWith('LTS version is provided. For LTS versions `check-latest` will be automatically set to true') | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve the latest version from manifest...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve LTS alias from manifest...') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith('Getting manifest from actions/node-versions@main') | ||||
|       expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached, getting manifest from actions/node-versions@main') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`LTS alias 'erbium' for Node version 'lts/erbium'`) | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`Found LTS release '12.16.2' for Node version 'lts/erbium'`) | ||||
|       expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'"); | ||||
|       expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); | ||||
|       expect(cnSpy).toHaveBeenCalledWith(`::add-path::${toolPath}/bin${osm.EOL}`); | ||||
|     }); | ||||
| @ -577,12 +582,12 @@ describe('setup-node', () => { | ||||
|       await main.run(); | ||||
|  | ||||
|       // assert | ||||
|       expect(logSpy).toHaveBeenCalledWith('LTS version is provided. For LTS versions `check-latest` will be automatically set to true') | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve the latest version from manifest...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve LTS alias from manifest...') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith('Getting manifest from actions/node-versions@main') | ||||
|       expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached, getting manifest from actions/node-versions@main') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`LTS alias 'erbium' for Node version 'lts/erbium'`) | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`Found LTS release '12.16.2' for Node version 'lts/erbium'`) | ||||
|       expect(logSpy).toHaveBeenCalledWith("Resolved as '12.16.2'"); | ||||
|       expect(logSpy).toHaveBeenCalledWith("Attempting to download 12.16.2..."); | ||||
|       expect(logSpy).toHaveBeenCalledWith("Attempting to download 12..."); | ||||
|       expect(logSpy).toHaveBeenCalledWith(`Acquiring 12.16.2 - ${os.arch} from ${expectedUrl}`); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Extracting ...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...'); | ||||
| @ -604,11 +609,11 @@ describe('setup-node', () => { | ||||
|       await main.run(); | ||||
|  | ||||
|       // assert | ||||
|       expect(logSpy).toHaveBeenCalledWith('LTS version is provided. For LTS versions `check-latest` will be automatically set to true') | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve the latest version from manifest...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve LTS alias from manifest...') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith('Getting manifest from actions/node-versions@main') | ||||
|       expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached, getting manifest from actions/node-versions@main') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`LTS alias '*' for Node version 'lts/*'`) | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`Found LTS release '14.0.0' for Node version 'lts/*'`) | ||||
|       expect(logSpy).toHaveBeenCalledWith("Resolved as '14.0.0'"); | ||||
|       expect(logSpy).toHaveBeenCalledWith(`Found in cache @ ${toolPath}`); | ||||
|       expect(cnSpy).toHaveBeenCalledWith(`::add-path::${toolPath}/bin${osm.EOL}`); | ||||
|     }); | ||||
| @ -632,12 +637,12 @@ describe('setup-node', () => { | ||||
|       await main.run(); | ||||
|  | ||||
|       // assert | ||||
|       expect(logSpy).toHaveBeenCalledWith('LTS version is provided. For LTS versions `check-latest` will be automatically set to true') | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve the latest version from manifest...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve LTS alias from manifest...') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith('Getting manifest from actions/node-versions@main') | ||||
|       expect(dbgSpy).not.toHaveBeenCalledWith('No manifest cached, getting manifest from actions/node-versions@main') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`LTS alias '*' for Node version 'lts/*'`) | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`Found LTS release '14.0.0' for Node version 'lts/*'`) | ||||
|       expect(logSpy).toHaveBeenCalledWith("Resolved as '14.0.0'"); | ||||
|       expect(logSpy).toHaveBeenCalledWith("Attempting to download 14.0.0..."); | ||||
|       expect(logSpy).toHaveBeenCalledWith("Attempting to download 14..."); | ||||
|       expect(logSpy).toHaveBeenCalledWith(`Acquiring 14.0.0 - ${os.arch} from ${expectedUrl}`); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Extracting ...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Adding to the cache ...'); | ||||
| @ -658,12 +663,9 @@ describe('setup-node', () => { | ||||
|       await main.run(); | ||||
|  | ||||
|       // assert | ||||
|       expect(logSpy).toHaveBeenCalledWith('LTS version is provided. For LTS versions `check-latest` will be automatically set to true') | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve the latest version from manifest...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Unable to resolve version from manifest...'); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`Unexpected LTS alias '' for Node version 'lts/'`) | ||||
|       expect(logSpy).toHaveBeenCalledWith('Failed to resolve version lts/ from manifest'); | ||||
|       expect(cnSpy).toHaveBeenCalledWith(`::error::Unable to find Node version 'lts/' for platform linux and architecture x64.${osm.EOL}`); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve LTS alias from manifest...') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith('Getting manifest from actions/node-versions@main') | ||||
|       expect(cnSpy).toHaveBeenCalledWith(`::error::Unexpected LTS alias '' for Node version 'lts/'${osm.EOL}`) | ||||
|     }); | ||||
|  | ||||
|     it('fail to find LTS version (lts/unknown)', async () => { | ||||
| @ -680,13 +682,33 @@ describe('setup-node', () => { | ||||
|       await main.run(); | ||||
|  | ||||
|       // assert | ||||
|       expect(logSpy).toHaveBeenCalledWith('LTS version is provided. For LTS versions `check-latest` will be automatically set to true') | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve the latest version from manifest...'); | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve LTS alias from manifest...') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith('Getting manifest from actions/node-versions@main') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`LTS alias 'unknown' for Node version 'lts/unknown'`) | ||||
|       expect(logSpy).toHaveBeenCalledWith('Unable to resolve version from manifest...'); | ||||
|       expect(dbgSpy).toHaveBeenCalledWith(`Unable to find LTS release 'unknown' for Node version 'lts/unknown'.`) | ||||
|       expect(logSpy).toHaveBeenCalledWith('Failed to resolve version lts/unknown from manifest'); | ||||
|       expect(cnSpy).toHaveBeenCalledWith(`::error::Unable to find Node version 'lts/unknown' for platform linux and architecture x64.${osm.EOL}`); | ||||
|       expect(cnSpy).toHaveBeenCalledWith(`::error::Unable to find LTS release 'unknown' for Node version 'lts/unknown'.${osm.EOL}`) | ||||
|     }); | ||||
|  | ||||
|     it('fail if manifest is not available', async () => { | ||||
|       // arrange | ||||
|       os.platform = 'linux'; | ||||
|       os.arch = 'x64'; | ||||
|  | ||||
|       inputs['node-version'] = 'lts/erbium'; | ||||
|       inputs.stable = 'true'; | ||||
|  | ||||
|       // ... but not in the local cache | ||||
|       findSpy.mockImplementation(() => ''); | ||||
|       getManifestSpy.mockImplementation(() => { | ||||
|         throw new Error('Unable to download manifest'); | ||||
|       }); | ||||
|  | ||||
|       // act | ||||
|       await main.run(); | ||||
|  | ||||
|       // assert | ||||
|       expect(logSpy).toHaveBeenCalledWith('Attempt to resolve LTS alias from manifest...') | ||||
|       expect(dbgSpy).toHaveBeenCalledWith('Getting manifest from actions/node-versions@main') | ||||
|       expect(cnSpy).toHaveBeenCalledWith(`::error::Unable to download manifest${osm.EOL}`) | ||||
|     }) | ||||
|   }) | ||||
| }); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Gordey Doronin
					Gordey Doronin