diff options
author | Jeffrey Wilcke <obscuren@users.noreply.github.com> | 2014-07-07 16:59:16 +0800 |
---|---|---|
committer | Jeffrey Wilcke <obscuren@users.noreply.github.com> | 2014-07-07 16:59:16 +0800 |
commit | 6fe9b4ab5e839be96eb1c4a619bc14fab622d8d1 (patch) | |
tree | b8b1218e456d3daaad4a36e6ba022323c3762038 /ethreact/reactor_test.go | |
parent | 9dab7dcc3c99d387ad2c0a1623b574d3023bdfae (diff) | |
download | dexon-6fe9b4ab5e839be96eb1c4a619bc14fab622d8d1.tar.gz dexon-6fe9b4ab5e839be96eb1c4a619bc14fab622d8d1.tar.zst dexon-6fe9b4ab5e839be96eb1c4a619bc14fab622d8d1.zip |
Revert "ethreact - Feature/ethutil refactor"
Diffstat (limited to 'ethreact/reactor_test.go')
-rw-r--r-- | ethreact/reactor_test.go | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/ethreact/reactor_test.go b/ethreact/reactor_test.go deleted file mode 100644 index 801a8abd0..000000000 --- a/ethreact/reactor_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package ethreact - -import ( - "fmt" - "testing" -) - -func TestReactorAdd(t *testing.T) { - reactor := New() - ch := make(chan Event) - reactor.Subscribe("test", ch) - if reactor.eventHandlers["test"] == nil { - t.Error("Expected new eventHandler to be created") - } - reactor.Unsubscribe("test", ch) - if reactor.eventHandlers["test"] != nil { - t.Error("Expected eventHandler to be removed") - } -} - -func TestReactorEvent(t *testing.T) { - var name string - reactor := New() - // Buffer the channel, so it doesn't block for this test - cap := 20 - ch := make(chan Event, cap) - reactor.Subscribe("even", ch) - reactor.Subscribe("odd", ch) - reactor.Post("even", "disappears") // should not broadcast if engine not started - reactor.Start() - for i := 0; i < cap; i++ { - if i%2 == 0 { - name = "even" - } else { - name = "odd" - } - reactor.Post(name, i) - } - reactor.Post("test", cap) // this should not block - i := 0 - reactor.Flush() - close(ch) - for event := range ch { - fmt.Printf("%d: %v", i, event) - if i%2 == 0 { - name = "even" - } else { - name = "odd" - } - if val, ok := event.Resource.(int); ok { - if i != val || event.Name != name { - t.Error("Expected event %d to be of type %s and resource %d, got ", i, name, i, val) - } - } else { - t.Error("Unable to cast") - } - i++ - } - if i != cap { - t.Error("excpected exactly %d events, got ", i) - } - reactor.Stop() -} |