aboutsummaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2018-05-11 07:53:17 +0300
committerTulir Asokan <tulir@maunium.net>2018-05-11 07:53:17 +0300
commitd53aa02c0f6cc0b153d227167fcf3b5c74e12d3a (patch)
tree4de52a96c2c49f35ea19e0333f3324f43f3645a2 /config
parent1dd036691e5af34c94c25d94bd7c8e5b1581dcb9 (diff)
Add test for DeleteSession() and fix potential bug in roomlist CheckTag()
Diffstat (limited to 'config')
-rw-r--r--config/session_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/config/session_test.go b/config/session_test.go
index 8b8bfff..5a7558b 100644
--- a/config/session_test.go
+++ b/config/session_test.go
@@ -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)
+}