mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-04 03:03:14 -05:00 
			
		
		
		
	
		
			
	
	
		
			35 lines
		
	
	
		
			632 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			35 lines
		
	
	
		
			632 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								package traffic
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"testing"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									"github.com/caddyserver/caddy"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func TestSetup(t *testing.T) {
							 | 
						||
| 
								 | 
							
									tests := []struct {
							 | 
						||
| 
								 | 
							
										input     string
							 | 
						||
| 
								 | 
							
										shouldErr bool
							 | 
						||
| 
								 | 
							
									}{
							 | 
						||
| 
								 | 
							
										// positive
							 | 
						||
| 
								 | 
							
										{`traffic`, false},
							 | 
						||
| 
								 | 
							
										// negative
							 | 
						||
| 
								 | 
							
										{`traffic fleeb`, true},
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									for i, test := range tests {
							 | 
						||
| 
								 | 
							
										c := caddy.NewTestController("dns", test.input)
							 | 
						||
| 
								 | 
							
										err := parse(c)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
										if test.shouldErr && err == nil {
							 | 
						||
| 
								 | 
							
											t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input)
							 | 
						||
| 
								 | 
							
										}
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
										if err != nil {
							 | 
						||
| 
								 | 
							
											if !test.shouldErr {
							 | 
						||
| 
								 | 
							
												t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err)
							 | 
						||
| 
								 | 
							
											}
							 | 
						||
| 
								 | 
							
										}
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								}
							 |