mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-04 03:03:14 -05:00 
			
		
		
		
	
		
			
	
	
		
			22 lines
		
	
	
		
			503 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			22 lines
		
	
	
		
			503 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								package test
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import (
							 | 
						||
| 
								 | 
							
									"io/ioutil"
							 | 
						||
| 
								 | 
							
									"os"
							 | 
						||
| 
								 | 
							
									"testing"
							 | 
						||
| 
								 | 
							
								)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								// Zone will create a temporary file on disk and returns the name and
							 | 
						||
| 
								 | 
							
								// cleanup function to remove it later.
							 | 
						||
| 
								 | 
							
								func Zone(t *testing.T, dir, zonefile string) (string, func(), error) {
							 | 
						||
| 
								 | 
							
									f, err := ioutil.TempFile(dir, "go-test-zone")
							 | 
						||
| 
								 | 
							
									if err != nil {
							 | 
						||
| 
								 | 
							
										return "", nil, err
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									if err := ioutil.WriteFile(f.Name(), []byte(zonefile), 0644); err != nil {
							 | 
						||
| 
								 | 
							
										return "", nil, err
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									rmFunc := func() { os.Remove(f.Name()) }
							 | 
						||
| 
								 | 
							
									return f.Name(), rmFunc, nil
							 | 
						||
| 
								 | 
							
								}
							 |