 Francis Lavoie
					
					6 years ago
						Francis Lavoie
					
					6 years ago
					
						
							committed by
							
								 GitHub
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: 4AEE18F83AFDEB23
						
					
				
			
		
		
		
	
		
			
				 2 changed files with 
12 additions and 
12 deletions
			 
			
		 
		
			
				- 
					
					
					 
					caddyconfig/caddyfile/dispenser.go
				
- 
					
					
					 
					caddyconfig/caddyfile/dispenser_test.go
				
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -17,6 +17,8 @@ package caddyfile | 
			
		
	
		
			
				
					|  |  |  | import ( | 
			
		
	
		
			
				
					|  |  |  | 	"errors" | 
			
		
	
		
			
				
					|  |  |  | 	"fmt" | 
			
		
	
		
			
				
					|  |  |  | 	"io" | 
			
		
	
		
			
				
					|  |  |  | 	"log" | 
			
		
	
		
			
				
					|  |  |  | 	"strings" | 
			
		
	
		
			
				
					|  |  |  | ) | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -37,6 +39,16 @@ func NewDispenser(tokens []Token) *Dispenser { | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | // NewTestDispenser parses input into tokens and creates a new
 | 
			
		
	
		
			
				
					|  |  |  | // Disenser for test purposes only; any errors are fatal.
 | 
			
		
	
		
			
				
					|  |  |  | func NewTestDispenser(input string) *Dispenser { | 
			
		
	
		
			
				
					|  |  |  | 	tokens, err := allTokens("Testfile", []byte(input)) | 
			
		
	
		
			
				
					|  |  |  | 	if err != nil && err != io.EOF { | 
			
		
	
		
			
				
					|  |  |  | 		log.Fatalf("getting all tokens from input: %v", err) | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	return NewDispenser(tokens) | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | // Next loads the next token. Returns true if a token
 | 
			
		
	
		
			
				
					|  |  |  | // was loaded; false otherwise. If false, all tokens
 | 
			
		
	
		
			
				
					|  |  |  | // have been consumed.
 | 
			
		
	
	
		
			
				
					|  |  | 
 | 
			
		
	
								
							
						
					 
					
				 
			 
		
			
			
			
			
			
			
				
				
					
						
							
								
									
	
		
			
				
					|  |  | @ -15,8 +15,6 @@ | 
			
		
	
		
			
				
					|  |  |  | package caddyfile | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import ( | 
			
		
	
		
			
				
					|  |  |  | 	"io" | 
			
		
	
		
			
				
					|  |  |  | 	"log" | 
			
		
	
		
			
				
					|  |  |  | 	"reflect" | 
			
		
	
		
			
				
					|  |  |  | 	"strings" | 
			
		
	
		
			
				
					|  |  |  | 	"testing" | 
			
		
	
	
		
			
				
					|  |  | @ -306,13 +304,3 @@ func TestDispenser_ArgErr_Err(t *testing.T) { | 
			
		
	
		
			
				
					|  |  |  | 		t.Errorf("Expected error message with custom message in it ('foobar'); got '%v'", err) | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | // NewTestDispenser parses input into tokens and creates a new
 | 
			
		
	
		
			
				
					|  |  |  | // Disenser for test purposes only; any errors are fatal.
 | 
			
		
	
		
			
				
					|  |  |  | func NewTestDispenser(input string) *Dispenser { | 
			
		
	
		
			
				
					|  |  |  | 	tokens, err := allTokens("Testfile", []byte(input)) | 
			
		
	
		
			
				
					|  |  |  | 	if err != nil && err != io.EOF { | 
			
		
	
		
			
				
					|  |  |  | 		log.Fatalf("getting all tokens from input: %v", err) | 
			
		
	
		
			
				
					|  |  |  | 	} | 
			
		
	
		
			
				
					|  |  |  | 	return NewDispenser(tokens) | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |