Browse Source
			
			
			fix testharness, dumps the current config, only if the config was successfully loaded (#3385)
			
			
				master
			
			
		 
		
			
				
					
						 Mark Sargent
					
					6 years ago
						Mark Sargent
					
					6 years ago
					
						
							committed by
							
								 GitHub
								GitHub
							
						 
					
				 
				
			 
		 
		
			
				
					
					No known key found for this signature in database
					
						
							GPG Key ID: 4AEE18F83AFDEB23
						
					
				
			
		
		
		
	
		
			
				 1 changed files with 
8 additions and 
4 deletions
			 
			
		 
		
			
				- 
					
					
					 
					caddytest/caddytest.go
				
				
				
					
						
							
								
									
	
		
		
			
				
					|  | @ -55,8 +55,9 @@ var ( | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | // Tester represents an instance of a test client.
 |  |  | // Tester represents an instance of a test client.
 | 
			
		
	
		
		
			
				
					|  |  | type Tester struct { |  |  | type Tester struct { | 
			
		
	
		
		
			
				
					
					|  |  | 	Client *http.Client |  |  | 	Client       *http.Client | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 	t      *testing.T |  |  | 	configLoaded bool | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | 	t            *testing.T | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | // NewTester will create a new testing client with an attached cookie jar
 |  |  | // NewTester will create a new testing client with an attached cookie jar
 | 
			
		
	
	
		
		
			
				
					|  | @ -73,7 +74,8 @@ func NewTester(t *testing.T) *Tester { | 
			
		
	
		
		
			
				
					|  |  | 			Jar:       jar, |  |  | 			Jar:       jar, | 
			
		
	
		
		
			
				
					|  |  | 			Timeout:   Default.TestRequestTimeout, |  |  | 			Timeout:   Default.TestRequestTimeout, | 
			
		
	
		
		
			
				
					|  |  | 		}, |  |  | 		}, | 
			
		
	
		
		
			
				
					
					|  |  | 		t: t, |  |  | 		configLoaded: false, | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | 		t:            t, | 
			
		
	
		
		
			
				
					|  |  | 	} |  |  | 	} | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | @ -114,7 +116,8 @@ func (tc *Tester) initServer(rawConfig string, configType string) error { | 
			
		
	
		
		
			
				
					|  |  | 	} |  |  | 	} | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 	tc.t.Cleanup(func() { |  |  | 	tc.t.Cleanup(func() { | 
			
		
	
		
		
			
				
					
					|  |  | 		if tc.t.Failed() { |  |  | 		if tc.t.Failed() && tc.configLoaded { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | 			res, err := http.Get(fmt.Sprintf("http://localhost:%d/config/", Default.AdminPort)) |  |  | 			res, err := http.Get(fmt.Sprintf("http://localhost:%d/config/", Default.AdminPort)) | 
			
		
	
		
		
			
				
					|  |  | 			if err != nil { |  |  | 			if err != nil { | 
			
		
	
		
		
			
				
					|  |  | 				tc.t.Log("unable to read the current config") |  |  | 				tc.t.Log("unable to read the current config") | 
			
		
	
	
		
		
			
				
					|  | @ -164,6 +167,7 @@ func (tc *Tester) initServer(rawConfig string, configType string) error { | 
			
		
	
		
		
			
				
					|  |  | 		return configLoadError{Response: string(body)} |  |  | 		return configLoadError{Response: string(body)} | 
			
		
	
		
		
			
				
					|  |  | 	} |  |  | 	} | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 	tc.configLoaded = true | 
			
		
	
		
		
			
				
					|  |  | 	return nil |  |  | 	return nil | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | 
 |