Allow verifying prerequisites!
This commit is contained in:
		
							parent
							
								
									e8bc9f0655
								
							
						
					
					
						commit
						c06ca5dad2
					
				
							
								
								
									
										8
									
								
								examples
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								examples
									
									
									
									
									
								
							| @ -44,4 +44,12 @@ | ||||
|   _bad-message - Bad Message | ||||
| } | ||||
| 
 | ||||
| _verify-prerequisites() { | ||||
|   if ! [[ -f /tmp/banana ]]; then | ||||
|     _bad-message There\'s not enough banana | ||||
|     _bad-message touch /tmp/banana to continue | ||||
|     exit 1 | ||||
|   fi | ||||
| } | ||||
| 
 | ||||
| source ⚡️ | ||||
|  | ||||
| @ -119,7 +119,7 @@ $ echo ' | ||||
| #!/usr/bin/env bash | ||||
| 
 | ||||
| _verify-prerequisites() { | ||||
|   docker ps &> /dev/null || echo 'Not enough docker' | ||||
|   docker ps &> /dev/null || (echo 'Not enough docker'; exit 1) | ||||
| } | ||||
| 
 | ||||
| ⚡️ubuntu() { | ||||
|  | ||||
							
								
								
									
										35
									
								
								test/test-prereqs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								test/test-prereqs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,35 @@ | ||||
| #!/usr/bin/env bash | ||||
| 
 | ||||
| testShouldBailIfRequirementsNotMet() { | ||||
|   echo ' | ||||
|   #!/usr/bin/env bash | ||||
| 
 | ||||
|   _verify-prerequisites() { false; } | ||||
|   ⚡️hello() { echo "Hello, World!" ; } | ||||
|   ' > go | ||||
| 
 | ||||
|   echo "source $REPO_ROOT/⚡️" >> go | ||||
|   chmod +x go | ||||
| 
 | ||||
|   try ./go | ||||
|   assertNotContains "$STDOUT" "hello" | ||||
|   assertEquals 1 "$EXIT_CODE" | ||||
| } | ||||
| 
 | ||||
| testShouldNotBailWhenPrereqsAreAllGood() { | ||||
|   echo ' | ||||
|   #!/usr/bin/env bash | ||||
| 
 | ||||
|   _verify-prerequisites() { true; } | ||||
|   ⚡️hello() { echo "Hello, World!" ; } | ||||
|   ' > go | ||||
| 
 | ||||
|   echo "source $REPO_ROOT/⚡️" >> go | ||||
|   chmod +x go | ||||
| 
 | ||||
|   try ./go | ||||
|   assertContains "$STDOUT" "hello" | ||||
|   assertEquals 0 "$EXIT_CODE" | ||||
| } | ||||
| 
 | ||||
| source $(dirname $0)/runner | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user