mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 00:10:55 +00:00 
			
		
		
		
	Add unit tests for restore (#62)
* Move archive file size to utils * Disable net connect with nock * Add unit tests for restore * Fix test names and test URL
This commit is contained in:
		
					parent
					
						
							
								ecf6eea708
							
						
					
				
			
			
				commit
				
					
						4b0709a0d5
					
				
			
		
					 8 changed files with 469 additions and 26 deletions
				
			
		| 
						 | 
				
			
			@ -1,3 +1,6 @@
 | 
			
		|||
import { Inputs } from "../constants";
 | 
			
		||||
 | 
			
		||||
// See: https://github.com/actions/toolkit/blob/master/packages/core/src/core.ts#L67
 | 
			
		||||
function getInputName(name: string): string {
 | 
			
		||||
    return `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -5,3 +8,22 @@ function getInputName(name: string): string {
 | 
			
		|||
export function setInput(name: string, value: string) {
 | 
			
		||||
    process.env[getInputName(name)] = value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
interface CacheInput {
 | 
			
		||||
    path: string;
 | 
			
		||||
    key: string;
 | 
			
		||||
    restoreKeys?: string[];
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function setInputs(input: CacheInput) {
 | 
			
		||||
    setInput(Inputs.Path, input.path);
 | 
			
		||||
    setInput(Inputs.Key, input.key);
 | 
			
		||||
    input.restoreKeys &&
 | 
			
		||||
        setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function clearInputs() {
 | 
			
		||||
    delete process.env[getInputName(Inputs.Path)];
 | 
			
		||||
    delete process.env[getInputName(Inputs.Key)];
 | 
			
		||||
    delete process.env[getInputName(Inputs.RestoreKeys)];
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue