mirror of
				https://github.com/coredns/coredns.git
				synced 2025-11-03 18:53:13 -05:00 
			
		
		
		
	
		
			
	
	
		
			18 lines
		
	
	
		
			290 B
		
	
	
	
		
			Go
		
	
	
	
	
	
		
		
			
		
	
	
			18 lines
		
	
	
		
			290 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| 
								 | 
							
								package uniq
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								import "testing"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								func TestForEach(t *testing.T) {
							 | 
						||
| 
								 | 
							
									u, i := New(), 0
							 | 
						||
| 
								 | 
							
									u.Set("test", func() error { i++; return nil })
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
									u.ForEach()
							 | 
						||
| 
								 | 
							
									if i != 1 {
							 | 
						||
| 
								 | 
							
										t.Errorf("Failed to executed f for %s", "test")
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									u.ForEach()
							 | 
						||
| 
								 | 
							
									if i != 1 {
							 | 
						||
| 
								 | 
							
										t.Errorf("Executed f twice instead of once")
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
								}
							 |