Add test for DeleteSession() and fix potential bug in roomlist CheckTag()

This commit is contained in:
Tulir Asokan 2018-05-11 07:53:17 +03:00
parent 1dd036691e
commit d53aa02c0f
2 changed files with 26 additions and 1 deletions

View File

@ -136,3 +136,28 @@ func TestSession_PutRoom(t *testing.T) {
assert.Equal(t, "foobar", reloadedRoom.PrevBatch, "%v %v", room, reloadedRoom)
assert.True(t, reloadedRoom.HasLeft, "%v %v", room, reloadedRoom)
}
func TestConfig_DeleteSession(t *testing.T) {
defer os.RemoveAll("/tmp/gomuks-test-12")
cfg := config.NewConfig("/tmp/gomuks-test-12", "/tmp/gomuks-test-12")
cfg.Load()
cfg.LoadSession("@tulir:maunium.net")
cfg.Session.SaveNextBatch("@tulir:maunium.net", "foobar")
cfg.Session.SaveFilterID("@tulir:maunium.net", "1234")
cfg.DeleteSession()
assert.Nil(t, cfg.Session)
sessFile, err := os.Stat("/tmp/gomuks-test-12/@tulir:maunium.net.session")
assert.Nil(t, sessFile)
assert.True(t, os.IsNotExist(err))
mediaDir, err := os.Stat("/tmp/gomuks-test-12/media")
assert.True(t, mediaDir.IsDir())
assert.Nil(t, err)
historyDir, err := os.Stat("/tmp/gomuks-test-12/history")
assert.True(t, historyDir.IsDir())
assert.Nil(t, err)
}

View File

@ -274,7 +274,7 @@ func (list *RoomList) CheckTag(tag string) {
tagRoomList, ok := list.items[tag]
if ok && tagRoomList.IsEmpty() {
delete(list.items, tag)
//delete(list.items, tag)
ok = false
}