Replace event dispatcher by the fork to allow emitting events with nil arguments

This commit is contained in:
ErickSkrauch 2020-03-30 15:44:12 +03:00
parent e3b9e3c069
commit 880182ccbf
No known key found for this signature in database
GPG Key ID: 669339FCBB30EE0E
3 changed files with 8 additions and 20 deletions

7
Gopkg.lock generated
View File

@ -15,12 +15,13 @@
version = "1.1"
[[projects]]
branch = "master"
digest = "1:33c6f6a0ee7d594d07ad9b67e93266f8a859ab2ddd882f8be19207162f40cce8"
branch = "publish_nil_values"
digest = "1:d02c8323070a3d8d8ca039d0d180198ead0a75eac4fb1003af812435a2b391e8"
name = "github.com/asaskevich/EventBus"
packages = ["."]
pruneopts = ""
revision = "d46933a94f05c6657d7b923fcf5ac563ee37ec79"
revision = "33b3bc6a7ddca2f99683c5c3ee86b24f80a7a075"
source = "https://github.com/erickskrauch/EventBus.git"
[[projects]]
digest = "1:c7b11da9bf0707e6920e1b361fbbbbe9b277ef3a198377baa4527f6e31049be0"

View File

@ -37,8 +37,9 @@ ignored = ["github.com/elyby/chrly"]
branch = "master"
[[constraint]]
branch = "master"
name = "github.com/asaskevich/EventBus"
source = "https://github.com/erickskrauch/EventBus.git"
branch = "publish_nil_values"
# Testing dependencies

View File

@ -17,20 +17,6 @@ type StatsReporterTestCase struct {
ExpectedCalls [][]interface{}
}
type NilErr struct {
}
func (n *NilErr) Error() string {
panic("don't call me")
}
// This let me to test events with nil error arguments.
// I can't just use `var nilErr error = nil`, because when Golang calls reflect.ValueOf()
// its returns only nil, without type. But when he calls reflection on specific structure (or pointer in this case),
// everything works fine. This is a memorial of 2 hours of my life, debugging and learning from the reflection
// about Go's types system. Nothing to regret.
var nilErr *NilErr = nil
var statsReporterTestCases = []*StatsReporterTestCase{
// Before request
{
@ -189,7 +175,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{
Events: map[string][]interface{}{
"mojang_textures:before_result": {"username", ""},
"mojang_textures:after_result": {"username", &mojang.SignedTexturesResponse{}, nilErr},
"mojang_textures:after_result": {"username", &mojang.SignedTexturesResponse{}, nil},
},
ExpectedCalls: [][]interface{}{
{"RecordTimer", "mock_prefix.mojang_textures.result_time", mock.AnythingOfType("time.Duration")},
@ -198,7 +184,7 @@ var statsReporterTestCases = []*StatsReporterTestCase{
{
Events: map[string][]interface{}{
"mojang_textures:textures:before_call": {"аааааааааааааааааааааааааааааааа"},
"mojang_textures:textures:after_call": {"аааааааааааааааааааааааааааааааа", &mojang.SignedTexturesResponse{}, nilErr},
"mojang_textures:textures:after_call": {"аааааааааааааааааааааааааааааааа", &mojang.SignedTexturesResponse{}, nil},
},
ExpectedCalls: [][]interface{}{
{"IncCounter", "mock_prefix.mojang_textures.textures.request", int64(1)},