mirror of
				https://github.com/coredns/coredns.git
				synced 2025-10-31 10:13:14 -04:00 
			
		
		
		
	Remove the word middleware (#1067)
* Rename middleware to plugin first pass; mostly used 'sed', few spots where I manually changed text. This still builds a coredns binary. * fmt error * Rename AddMiddleware to AddPlugin * Readd AddMiddleware to remain backwards compat
This commit is contained in:
		
							
								
								
									
										65
									
								
								plugin/secondary/setup_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										65
									
								
								plugin/secondary/setup_test.go
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,65 @@ | ||||
| package secondary | ||||
|  | ||||
| import ( | ||||
| 	"testing" | ||||
|  | ||||
| 	"github.com/mholt/caddy" | ||||
| ) | ||||
|  | ||||
| func TestSecondaryParse(t *testing.T) { | ||||
| 	tests := []struct { | ||||
| 		inputFileRules string | ||||
| 		shouldErr      bool | ||||
| 		transferFrom   string | ||||
| 		zones          []string | ||||
| 	}{ | ||||
| 		{ | ||||
| 			`secondary`, | ||||
| 			false, // TODO(miek): should actually be true, because without transfer lines this does not make sense | ||||
| 			"", | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			`secondary { | ||||
| 				transfer from 127.0.0.1 | ||||
| 				transfer to 127.0.0.1 | ||||
| 			}`, | ||||
| 			false, | ||||
| 			"127.0.0.1:53", | ||||
| 			nil, | ||||
| 		}, | ||||
| 		{ | ||||
| 			`secondary example.org { | ||||
| 				transfer from 127.0.0.1 | ||||
| 				transfer to 127.0.0.1 | ||||
| 			}`, | ||||
| 			false, | ||||
| 			"127.0.0.1:53", | ||||
| 			[]string{"example.org."}, | ||||
| 		}, | ||||
| 	} | ||||
|  | ||||
| 	for i, test := range tests { | ||||
| 		c := caddy.NewTestController("dns", test.inputFileRules) | ||||
| 		s, err := secondaryParse(c) | ||||
|  | ||||
| 		if err == nil && test.shouldErr { | ||||
| 			t.Fatalf("Test %d expected errors, but got no error", i) | ||||
| 		} else if err != nil && !test.shouldErr { | ||||
| 			t.Fatalf("Test %d expected no errors, but got '%v'", i, err) | ||||
| 		} | ||||
|  | ||||
| 		for i, name := range test.zones { | ||||
| 			if x := s.Names[i]; x != name { | ||||
| 				t.Fatalf("Test %d zone names don't match expected %q, but got %q", i, name, x) | ||||
| 			} | ||||
| 		} | ||||
|  | ||||
| 		// This is only set *iff* we have a zone (i.e. not in all tests above) | ||||
| 		for _, v := range s.Z { | ||||
| 			if x := v.TransferFrom[0]; x != test.transferFrom { | ||||
| 				t.Fatalf("Test %d transform from names don't match expected %q, but got %q", i, test.transferFrom, x) | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
		Reference in New Issue
	
	Block a user