From 4ee035766b007dcdd9a1d89962b0e03ee0f60c17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Fri, 12 May 2017 09:49:57 +0200 Subject: [PATCH] Fix ChannelStore regression --- storage/channel.go | 5 +++-- storage/channel_test.go | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/channel.go b/storage/channel.go index a946c714..c2858dfb 100644 --- a/storage/channel.go +++ b/storage/channel.go @@ -93,8 +93,9 @@ func (c *ChannelStore) SetUsers(users []string, server, channel string) { c.users[server] = make(map[string][]*ChannelStoreUser) } - for _, nick := range users { - c.users[server][channel] = append(c.users[server][channel], NewChannelStoreUser(nick)) + c.users[server][channel] = make([]*ChannelStoreUser, len(users)) + for i, nick := range users { + c.users[server][channel][i] = NewChannelStoreUser(nick) } c.userLock.Unlock() diff --git a/storage/channel_test.go b/storage/channel_test.go index 822490cf..f35a486f 100644 --- a/storage/channel_test.go +++ b/storage/channel_test.go @@ -11,6 +11,8 @@ func TestGetSetUsers(t *testing.T) { users := []string{"a", "b"} channelStore.SetUsers(users, "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) {