-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expand the API of SyncDispatcher (#191)
* feat: add more methods * feat: expand the api of SyncDispatcher * feat: expand the api of SyncDispatcher * docs: comment
- Loading branch information
Showing
4 changed files
with
319 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package events | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/DoNewsCode/core/contract" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type mockListener1 struct{} | ||
|
||
func (m mockListener1) Listen() (topic interface{}) { | ||
panic("implement me") | ||
} | ||
|
||
func (m mockListener1) Process(ctx context.Context, payload interface{}) error { | ||
panic("implement me") | ||
} | ||
|
||
func (m mockListener1) Equals(listener contract.Listener) bool { | ||
return true | ||
} | ||
|
||
type mockListener2 struct{} | ||
|
||
func (m mockListener2) Listen() (topic interface{}) { | ||
panic("implement me") | ||
} | ||
|
||
func (m mockListener2) Process(ctx context.Context, payload interface{}) error { | ||
panic("implement me") | ||
} | ||
|
||
func (m mockListener2) Equals(listener contract.Listener) bool { | ||
return false | ||
} | ||
|
||
func TestOnceListener(t *testing.T) { | ||
once := onceListener{nil, mockListener1{}} | ||
assert.True(t, once.Equals(mockListener1{})) | ||
|
||
once = onceListener{nil, mockListener2{}} | ||
assert.False(t, once.Equals(mockListener2{})) | ||
} |