Make removeUser public

This commit is contained in:
Anant Prakash 2018-07-31 19:25:58 +05:30
parent 14850f9c33
commit 48ca0d963f
No known key found for this signature in database
GPG key ID: C5D399F626523045
2 changed files with 5 additions and 5 deletions

View file

@ -85,12 +85,12 @@ func (t *TypingCache) addUser(userID, roomID string, expiryTimer *time.Timer) {
// This removes the user.
func (t *TypingCache) timeoutCallback(userID, roomID string) func() {
return func() {
t.removeUser(userID, roomID)
t.RemoveUser(userID, roomID)
}
}
// removeUser with mutex lock & stop the timer.
func (t *TypingCache) removeUser(userID, roomID string) {
// RemoveUser with mutex lock & stop the timer.
func (t *TypingCache) RemoveUser(userID, roomID string) {
t.Lock()
defer t.Unlock()

View file

@ -33,7 +33,7 @@ func TestTypingCache(t *testing.T) {
testGetTypingUsers(t, tCache)
})
t.Run("removeUser", func(t *testing.T) {
t.Run("RemoveUser", func(t *testing.T) {
testRemoveUser(t, tCache)
})
}
@ -90,7 +90,7 @@ func testRemoveUser(t *testing.T, tCache *TypingCache) {
}
length := len(tt.userIDs)
tCache.removeUser(tt.userIDs[length-1], tt.roomID)
tCache.RemoveUser(tt.userIDs[length-1], tt.roomID)
expLeftUsers := tt.userIDs[:length-1]
if leftUsers := tCache.GetTypingUsers(tt.roomID); !test.UnsortedStringSliceEqual(leftUsers, expLeftUsers) {
t.Errorf("Response after removal is unexpected. Want = %s, got = %s", leftUsers, expLeftUsers)