Commit Graph

402 Commits

Author SHA1 Message Date
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
Alex Bramley eea12a554b Hmm, slice out of range error, wtf x3! 2011-10-22 16:44:28 +01:00
Alex Bramley 1df07d2ff6 Hmm, slice out of range error, wtf x2. 2011-10-22 16:42:24 +01:00
Alex Bramley ebc34cdce5 Hmm, slice out of range error, wtf. 2011-10-22 16:40:47 +01:00
Alex Bramley 4ee7aac968 oops, this is not a Logger. 2011-10-22 16:18:57 +01:00
Alex Bramley dee808a263 Move logger mocks to a non-test file so they can be used elsewhere. 2011-10-22 16:15:46 +01:00
Alex Bramley 2467e5cc93 More tests for the logging package. 2011-10-22 15:43:13 +01:00
Alex Bramley c769723596 Rewrite logging package for great justice.
Allowing people to use the static functions to log things makes testing
hard, so I've removed them. I've also rewritten things to allow logging
different levels to separate files.
2011-10-22 12:06:18 +01:00
Alex Bramley 7be7e79c78 Oops, missed a bit. 2011-10-20 00:23:54 +01:00
Alex Bramley 111a23d87c Epic refactor of the refactor. 2011-10-20 00:10:33 +01:00
Alex Bramley 7f6e5fc7d9 Use NewNick and NewChannel in tests. 2011-10-13 23:19:31 +01:00
Alex Bramley 2c333e0e9a Ditch initialise() functions and just make constructors better. 2011-10-13 22:48:04 +01:00
Alex Bramley 6266eba245 Slight fixes to NewChannel and tests for st's Channel methods. 2011-10-13 22:31:09 +01:00
Alex Bramley 9163b9af7a Slight fixes to ReNick and tests for the rest of st's Nick methods. 2011-10-13 20:44:44 +01:00
Alex Bramley 4c6c503069 Beginning of state tracker unit tests. 2011-10-12 23:06:46 +01:00
Alex Bramley b2ac2929d2 Break state tracker into multiple files. 2011-10-12 22:59:52 +01:00
Alex Bramley a26a940e6d Comment changes and cosmetics for state pkg. 2011-10-08 10:57:10 +01:00