| 
									
										
										
										
											2016-08-19 17:14:17 -07:00
										 |  |  | package pprof
 | 
					
						
							| 
									
										
										
										
											2016-04-28 10:26:58 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-19 17:14:17 -07:00
										 |  |  | import (
 | 
					
						
							|  |  |  | 	"testing"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	"github.com/mholt/caddy"
 | 
					
						
							|  |  |  | )
 | 
					
						
							| 
									
										
										
										
											2016-04-28 10:26:58 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | func TestPProf(t *testing.T) {
 | 
					
						
							|  |  |  | 	tests := []struct {
 | 
					
						
							|  |  |  | 		input     string
 | 
					
						
							|  |  |  | 		shouldErr bool
 | 
					
						
							|  |  |  | 	}{
 | 
					
						
							|  |  |  | 		{`pprof`, false},
 | 
					
						
							| 
									
										
										
										
											2017-04-24 10:27:26 -04:00
										 |  |  | 		{`pprof 1.2.3.4:1234`, false},
 | 
					
						
							|  |  |  | 		{`pprof :1234`, false},
 | 
					
						
							| 
									
										
										
										
											2016-04-28 10:26:58 +01:00
										 |  |  | 		{`pprof {}`, true},
 | 
					
						
							|  |  |  | 		{`pprof /foo`, true},
 | 
					
						
							|  |  |  | 		{`pprof {
 | 
					
						
							|  |  |  |             a b
 | 
					
						
							|  |  |  |         }`, true},
 | 
					
						
							|  |  |  | 		{`pprof
 | 
					
						
							|  |  |  |           pprof`, true},
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | 	for i, test := range tests {
 | 
					
						
							| 
									
										
										
										
											2016-08-19 17:14:17 -07:00
										 |  |  | 		c := caddy.NewTestController("dns", test.input)
 | 
					
						
							|  |  |  | 		err := setup(c)
 | 
					
						
							| 
									
										
										
										
											2016-04-28 10:26:58 +01:00
										 |  |  | 		if test.shouldErr && err == nil {
 | 
					
						
							|  |  |  | 			t.Errorf("Test %v: Expected error but found nil", i)
 | 
					
						
							|  |  |  | 		} else if !test.shouldErr && err != nil {
 | 
					
						
							|  |  |  | 			t.Errorf("Test %v: Expected no error but found error: %v", i, err)
 | 
					
						
							|  |  |  | 		}
 | 
					
						
							|  |  |  | 	}
 | 
					
						
							|  |  |  | }
 |