diff options
author | Tulir Asokan <tulir@maunium.net> | 2018-05-10 20:31:11 +0300 |
---|---|---|
committer | Tulir Asokan <tulir@maunium.net> | 2018-05-10 20:31:19 +0300 |
commit | 706f4c44048e59bf914877f6f8bf17ad9915a65c (patch) | |
tree | 733eb0dc2d88cb0fd245b896fb538dd9b5ab98f6 /matrix/matrix.go | |
parent | 1e6b5996491d7d27147a0dea2b52c36577820d63 (diff) |
Add tests for JoinRoom, LeaveRoom and Download
Diffstat (limited to 'matrix/matrix.go')
-rw-r--r-- | matrix/matrix.go | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/matrix/matrix.go b/matrix/matrix.go index de65b60..cdd4ed5 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -439,10 +439,6 @@ func (c *Container) SendTyping(roomID string, typing bool) { // JoinRoom makes the current user try to join the given room. func (c *Container) JoinRoom(roomID, server string) (*rooms.Room, error) { - if len(roomID) == 0 { - return nil, fmt.Errorf("invalid room ID") - } - resp, err := c.client.JoinRoom(roomID, server, nil) if err != nil { return nil, err @@ -456,10 +452,6 @@ func (c *Container) JoinRoom(roomID, server string) (*rooms.Room, error) { // LeaveRoom makes the current user leave the given room. func (c *Container) LeaveRoom(roomID string) error { - if len(roomID) == 0 { - return fmt.Errorf("invalid room ID") - } - _, err := c.client.LeaveRoom(roomID) if err != nil { return err @@ -500,7 +492,8 @@ func (c *Container) Download(mxcURL string) (data []byte, hs, id string, err err id = parts[2] cacheFile := c.GetCachePath(hs, id) - if _, err = os.Stat(cacheFile); err != nil { + var info os.FileInfo + if info, err = os.Stat(cacheFile); err == nil && !info.IsDir() { data, err = ioutil.ReadFile(cacheFile) if err == nil { return |