summaryrefslogtreecommitdiffstats
path: root/api/channel_test.go
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2016-12-12 06:30:37 +0100
committerCorey Hulen <corey@hulen.com>2016-12-11 21:30:37 -0800
commitf0d71d87899967335210b9130a7e2b8d180bef46 (patch)
treed2941b8870e87677a84821dd32454a28594c889b /api/channel_test.go
parentb5fcfd608c0e9ef764cace7328653e4d4c47a061 (diff)
downloadchat-f0d71d87899967335210b9130a7e2b8d180bef46.tar.gz
chat-f0d71d87899967335210b9130a7e2b8d180bef46.tar.bz2
chat-f0d71d87899967335210b9130a7e2b8d180bef46.zip
Add API call to get a channel by its name (#4700)
* add api for getByChannelName * add tests * fix test * rename and tests * check for permissions and test
Diffstat (limited to 'api/channel_test.go')
-rw-r--r--api/channel_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/api/channel_test.go b/api/channel_test.go
index 5b44b6ab0..2414b51e2 100644
--- a/api/channel_test.go
+++ b/api/channel_test.go
@@ -10,6 +10,7 @@ import (
"time"
"github.com/mattermost/platform/model"
+ "github.com/mattermost/platform/store"
"github.com/mattermost/platform/utils"
)
@@ -1632,3 +1633,30 @@ func TestAutocompleteChannels(t *testing.T) {
t.Fatal("should have failed - bad team id")
}
}
+
+func TestGetChannelByName(t *testing.T) {
+ th := Setup().InitBasic()
+ Client := th.BasicClient
+
+ if _, err := Client.GetChannelByName(th.BasicChannel.Name); err != nil {
+ t.Fatal("Failed to get channel")
+ }
+
+ if _, err := Client.GetChannelByName("InvalidChannelName"); err == nil {
+ t.Fatal("Failed to get team")
+ }
+
+ Client.Must(Client.Logout())
+
+ user2 := &model.User{Email: "success+" + model.NewId() + "@simulator.amazonses.com", Nickname: "Jabba the Hutt", Password: "passwd1"}
+ user2 = Client.Must(Client.CreateUser(user2, "")).Data.(*model.User)
+ store.Must(Srv.Store.User().VerifyEmail(user2.Id))
+
+ Client.SetTeamId(th.BasicTeam.Id)
+
+ Client.Login(user2.Email, "passwd1")
+
+ if _, err := Client.GetChannelByName(th.BasicChannel.Name); err == nil {
+ t.Fatal("Should fail due not enough permissions")
+ }
+}