mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 21:39:09 +08:00 
			
		
		
		
	Add Eric's e2e test change to get more coverage
This commit is contained in:
		
							
								
								
									
										11
									
								
								__tests__/create-cache-files.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										11
									
								
								__tests__/create-cache-files.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
# Validate args
 | 
			
		||||
prefix="$1"
 | 
			
		||||
if [ -z "$prefix" ]; then
 | 
			
		||||
  echo "Must supply prefix argument"
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
mkdir test-cache
 | 
			
		||||
echo "$prefix $GITHUB_RUN_ID" > test-cache/test-file.txt
 | 
			
		||||
@@ -51,7 +51,7 @@ test("extract GNU tar", async () => {
 | 
			
		||||
 | 
			
		||||
        await tar.extractTar(archivePath, targetDirectory);
 | 
			
		||||
 | 
			
		||||
        expect(execMock).toHaveBeenCalledTimes(2);
 | 
			
		||||
        expect(execMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
        expect(execMock).toHaveBeenLastCalledWith(`"tar"`, [
 | 
			
		||||
            "-xz",
 | 
			
		||||
            "-f",
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										30
									
								
								__tests__/verify-cache-files.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										30
									
								
								__tests__/verify-cache-files.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
# Validate args
 | 
			
		||||
prefix="$1"
 | 
			
		||||
if [ -z "$prefix" ]; then
 | 
			
		||||
  echo "Must supply prefix argument"
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Sanity check GITHUB_RUN_ID defined
 | 
			
		||||
if [ -z "$GITHUB_RUN_ID" ]; then
 | 
			
		||||
  echo "GITHUB_RUN_ID not defined"
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Verify file exists
 | 
			
		||||
file="test-cache/test-file.txt"
 | 
			
		||||
echo "Checking for $file"
 | 
			
		||||
if [ ! -e $file ]; then
 | 
			
		||||
  echo "File does not exist"
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
# Verify file content
 | 
			
		||||
content="$(cat $file)"
 | 
			
		||||
echo "File content:\n$content"
 | 
			
		||||
if [ -z "$(echo $content | grep --fixed-strings "$prefix $GITHUB_RUN_ID")" ]; then
 | 
			
		||||
  echo "Unexpected file content"
 | 
			
		||||
  exit 1
 | 
			
		||||
fi
 | 
			
		||||
		Reference in New Issue
	
	Block a user