mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-30 17:53:21 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			47 lines
		
	
	
		
			842 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			842 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package traffic
 | |
| 
 | |
| import (
 | |
| 	"testing"
 | |
| 
 | |
| 	"github.com/caddyserver/caddy"
 | |
| )
 | |
| 
 | |
| func TestSetup(t *testing.T) {
 | |
| 	/*
 | |
| 		c := caddy.NewTestController("dns", `traffic grpc://bla`)
 | |
| 		if err := setup(c); err != nil {
 | |
| 			t.Fatalf("Test 1, expected no errors, but got: %q", err)
 | |
| 		}
 | |
| 	*/
 | |
| }
 | |
| 
 | |
| func TestParse(t *testing.T) {
 | |
| 	tests := []struct {
 | |
| 		input     string
 | |
| 		shouldErr bool
 | |
| 	}{
 | |
| 		// fail
 | |
| 		{`traffic {
 | |
| 			id bla bla
 | |
| 		}`, true},
 | |
| 		{`traffic {
 | |
| 			node bla bla
 | |
| 		}`, true},
 | |
| 	}
 | |
| 	for i, test := range tests {
 | |
| 		c := caddy.NewTestController("dns", test.input)
 | |
| 		_, err := parse(c)
 | |
| 		if test.shouldErr && err == nil {
 | |
| 			t.Errorf("Test %v: Expected error but found nil", i)
 | |
| 			continue
 | |
| 		} else if !test.shouldErr && err != nil {
 | |
| 			t.Errorf("Test %v: Expected no error but found error: %v", i, err)
 | |
| 			continue
 | |
| 		}
 | |
| 
 | |
| 		if test.shouldErr {
 | |
| 			continue
 | |
| 		}
 | |
| 	}
 | |
| }
 |