mirror of
				https://github.com/fluffle/goirc
				synced 2025-10-30 01:38:05 +00:00 
			
		
		
		
	Add mock dispatcher factory that tests an event fired; use it in Test001().
This commit is contained in:
		
							parent
							
								
									59b18b038b
								
							
						
					
					
						commit
						5ff77fc2f9
					
				
					 2 changed files with 15 additions and 8 deletions
				
			
		|  | @ -1,6 +1,9 @@ | |||
| package client | ||||
| 
 | ||||
| import "testing" | ||||
| import ( | ||||
| 	"strings" | ||||
| 	"testing" | ||||
| ) | ||||
| 
 | ||||
| func setUp(t *testing.T) (*mockNetConn, *Conn) { | ||||
| 	c := New("test", "test", "Testing IRC") | ||||
|  | @ -17,3 +20,11 @@ type mockDispatcher func(string, ...interface{}) | |||
| func (d mockDispatcher) Dispatch(name string, ev ...interface{}) { | ||||
| 	d(name, ev...) | ||||
| } | ||||
| 
 | ||||
| func WasEventDispatched(name string, flag *bool) mockDispatcher { | ||||
| 	return mockDispatcher(func(n string, ev ...interface{}) { | ||||
| 		if n == strings.ToLower(name) { | ||||
| 			*flag = true | ||||
| 		} | ||||
| 	}) | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue