Fix ChannelStore regression

This commit is contained in:
Ken-Håvard Lieng 2017-05-12 09:49:57 +02:00
parent 71177254b4
commit 4ee035766b
2 changed files with 5 additions and 2 deletions

View File

@ -93,8 +93,9 @@ func (c *ChannelStore) SetUsers(users []string, server, channel string) {
c.users[server] = make(map[string][]*ChannelStoreUser) c.users[server] = make(map[string][]*ChannelStoreUser)
} }
for _, nick := range users { c.users[server][channel] = make([]*ChannelStoreUser, len(users))
c.users[server][channel] = append(c.users[server][channel], NewChannelStoreUser(nick)) for i, nick := range users {
c.users[server][channel][i] = NewChannelStoreUser(nick)
} }
c.userLock.Unlock() c.userLock.Unlock()

View File

@ -11,6 +11,8 @@ func TestGetSetUsers(t *testing.T) {
users := []string{"a", "b"} users := []string{"a", "b"}
channelStore.SetUsers(users, "srv", "#chan") channelStore.SetUsers(users, "srv", "#chan")
assert.Equal(t, users, channelStore.GetUsers("srv", "#chan")) assert.Equal(t, users, channelStore.GetUsers("srv", "#chan"))
channelStore.SetUsers(users, "srv", "#chan")
assert.Equal(t, users, channelStore.GetUsers("srv", "#chan"))
} }
func TestAddRemoveUser(t *testing.T) { func TestAddRemoveUser(t *testing.T) {