Commit Graph

418 Commits

Author SHA1 Message Date
Alex Bramley 6a54622df9 Make mockNetConn more likely to expose racy conditions.
Use buffered channels so that Close() returns without waiting.
Use an array of three channels rather than appending to a slice.
2011-11-11 10:48:58 +00:00
Alex Bramley dc524420b0 Test write(). Fix bug where return of Flush() was not checked. 2011-11-11 10:17:17 +00:00
Alex Bramley 19ea7138e5 Test runLoop(). Needed a lot of sleeps... 2011-11-11 09:23:12 +00:00
Alex Bramley 9ccb0a39ab Test recv(). 2011-11-11 08:35:23 +00:00
Alex Bramley 0d4e83ea7f Fix length bug in mockNetChan.
Using the length of the provided buffer is dangerous after the first buffered
read from it, as it'll be the length of the buffer size...
2011-11-11 08:34:55 +00:00
Alex Bramley 38cd23891a Streamline timers in mockNetConn slightly. 2011-11-11 08:00:18 +00:00
Alex Bramley bfdd895ca6 Test send(). 2011-11-11 07:59:16 +00:00
Alex Bramley d4aceddcd7 Test Client creation and ST enable/disable. 2011-11-10 15:06:44 +00:00
Alex Bramley cab3d3da21 Fixes to gomock output so tests using mock pass. reflect.DeepEqual is picky. 2011-11-10 15:05:22 +00:00
Alex Bramley 80d8cd4ea7 Update README and example client once more. 2011-11-09 22:06:54 +00:00
Alex Bramley 8239bc4b6e Unit test adding and deleting handlers and events. 2011-11-09 21:54:14 +00:00
Alex Bramley 177149fd3c Remove lists when empty after deleting elements. 2011-11-09 21:38:47 +00:00
Alex Bramley bdb5c9b1a0 Squash a couple of bugs found by the unit tests. 2011-11-09 21:14:24 +00:00
Alex Bramley cdd08b2de8 Remove extraneous use of append in serialDispatch. 2011-11-09 20:30:37 +00:00
Alex Bramley a271cc06f3 Use mock dispatcher for testing event triggering. 2011-11-07 14:53:07 +00:00
Alex Bramley e04065dcbe Hmm, code generation failure 2011-11-07 13:53:50 +00:00
Alex Bramley d821d69f1c Add mock event registry. 2011-11-07 13:49:00 +00:00
Alex Bramley 3feaa7f302 Use a static map of event handlers for internal handlers too. 2011-11-07 13:44:03 +00:00
Alex Bramley aa75e0e0c6 Make enabling/disabling state-tracking easier. Improve constructors. 2011-11-07 13:34:13 +00:00
Alex Bramley 6e87169e2c Make API for adding/deleting handlers more coherent.
Previously, it was possible to add the same handler (as returned by NewHandler)
to multiple different event lists, but DelHandler only removed a handler from
*all* event lists it was present in. This may not be wanted behaviour, and
reduces control over the event lists.

Instead, allow both Add and DelHandler to take a variadic list of events to
add or delete handlers from.
2011-11-07 13:13:46 +00:00
Alex Bramley 4853024928 Nuke extraneous makefiles, no longer needed. 2011-11-06 06:26:59 +00:00
Alex Bramley caa9429a74 Update README. 2011-11-06 05:22:02 +00:00
Alex Bramley 2bc8238f8e Move state-related handlers to their own file for clarity. 2011-11-06 05:11:49 +00:00
Alex Bramley 2389f03d45 Update example client. 2011-11-06 05:08:28 +00:00
Alex Bramley 85097043cf Epic final commit for nick/chan/logging/testing refactor.
* Brings logging changes to client library.
* Brings state tracker to client library.
* Rewrites all tests to use mock logger and mock state tracker.
* Makes state tracking optional, finally.
* Shaves yaks until they are almost completely bald.
2011-11-06 04:56:46 +00:00
Alex Bramley 69d52270b6 Convert state tracker to use gomock logging for tests. 2011-11-05 12:22:04 +00:00
Alex Bramley d0f0175d7f Oops. Missed String() from interface. 2011-11-05 09:30:32 +00:00
Alex Bramley aa12177399 My mock is clunky for external use, but works well for internal testing. Switch to gomock. 2011-11-05 09:27:44 +00:00
Alex Bramley b1037b2603 Add String() method for stateTracker. 2011-11-05 06:06:59 +00:00
Alex Bramley fdba74e8c0 Shave the yaks in state's tests. 2011-11-05 06:06:40 +00:00
Alex Bramley 588a3168ac More logging yak-shaving:
* Change Mock API to match mockNetConn Expect* calls.
* Make logging.NewMock take and store *testing.T.
* Add a level-agnostic Expect().
* Make writerMap an externally accessible type.
* Adjust tests to take this shaving into account.
2011-11-05 05:56:45 +00:00
Alex Bramley cfffcf2a85 Add a method to wipe a state tracker clean. 2011-11-05 02:25:25 +00:00
Alex Bramley 60cd5b975f Test Channel.ParseModes(). 2011-11-03 04:15:12 +00:00
Alex Bramley 2a6f19dc83 Start of channel tests. 2011-11-03 03:12:32 +00:00
Alex Bramley b88983ceaf Test Nick.ParseModes(). 2011-11-03 03:01:50 +00:00
Alex Bramley 75112d67e2 More nick tests. 2011-10-27 18:43:34 +01:00
Alex Bramley 1c39dbecbb Remove extraneous logging level setting. 2011-10-27 18:43:08 +01:00
Alex Bramley 049942ff2f Hmm, using a fixed-length filename doesn't work when you're allowing other people to use your mocks. 2011-10-27 18:37:55 +01:00
Alex Bramley 97783df463 Make mock loggers log everything to avoid stupids. 2011-10-27 18:28:43 +01:00
Alex Bramley 2f5d4d86a5 Really sort out indentation. 2011-10-27 18:07:56 +01:00
Alex Bramley 748db6b5d2 Test for dissociation, also ensure both nick and channel passed to {A,Di}ssociate are currently tracked. 2011-10-27 17:54:23 +01:00
Alex Bramley 74ef93abde Fix behaviour of CheckWrittenAtLevel() slightly:
1) Adjust alignments for exp/got correctly.
2) Print expected string when nothing logged at level.
3) Check to ensure no unexpected logging occurred at other levels when nothing
   logged at expected level.
2011-10-27 17:48:15 +01:00
Alex Bramley 47dd5b3430 We need to be able to get at ChanPrivs easily. 2011-10-27 17:03:01 +01:00
Alex Bramley 2603e0984c Test nick <-> channel association. 2011-10-27 16:55:33 +01:00
Alex Bramley 93508c79f1 Similar nick <-> channel dissociation tests in DelChannel(). 2011-10-27 16:41:56 +01:00
Alex Bramley 8771f1db77 Test nick<->channel dissociation in DelNick(). 2011-10-27 16:04:45 +01:00
Alex Bramley 6ded98b9e5 Moar testing and updates. 2011-10-22 23:58:06 +01:00
Alex Bramley 1fbd0a8b17 Switch to using and propagating logger. 2011-10-22 23:57:22 +01:00
Alex Bramley 88a664833e Oops. I was just being fail. 2011-10-22 16:59:28 +01:00
Alex Bramley 63c7915933 Srsly, fffffuuuu. 2011-10-22 16:45:53 +01:00