summaryrefslogtreecommitdiffstats
path: root/api/cli_test.go
diff options
context:
space:
mode:
authorCorey Hulen <corey@hulen.com>2016-07-06 10:11:21 -0800
committerChristopher Speller <crspeller@gmail.com>2016-07-06 14:11:21 -0400
commitb1520d0b9458d1dab09d9e3e05dd7522fc28ba57 (patch)
tree6500ca9d516ddf456eaf4edfe4b27617a7490bf8 /api/cli_test.go
parent26c91e73fef89b1d4a0ef04ef39589243d411752 (diff)
downloadchat-b1520d0b9458d1dab09d9e3e05dd7522fc28ba57.tar.gz
chat-b1520d0b9458d1dab09d9e3e05dd7522fc28ba57.tar.bz2
chat-b1520d0b9458d1dab09d9e3e05dd7522fc28ba57.zip
PLT-3512 adding join/leave channel to the CLI (#3498)
* PLT-3512 adding join/leave channel to the CLI * PLT-3512 adding list channels to the CLI * PLT-3512 adding restore channel * Adding make run-cli command * Updating txt * Fixing txt purposed by PMs
Diffstat (limited to 'api/cli_test.go')
-rw-r--r--api/cli_test.go169
1 files changed, 169 insertions, 0 deletions
diff --git a/api/cli_test.go b/api/cli_test.go
index 12f38b54a..8184c2e06 100644
--- a/api/cli_test.go
+++ b/api/cli_test.go
@@ -135,6 +135,175 @@ func TestCliAssignRole(t *testing.T) {
}
}
+func TestCliJoinChannel(t *testing.T) {
+ if disableCliTests {
+ return
+ }
+
+ th := Setup().InitBasic()
+ channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
+
+ // These test cannot run since this feature requires an enteprise license
+
+ // cmd := exec.Command("bash", "-c", `go run ../mattermost.go -join_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`" -email="`+th.BasicUser2.Email+`"`)
+ // output, err := cmd.CombinedOutput()
+ // if err != nil {
+ // t.Log(string(output))
+ // t.Fatal(err)
+ // }
+
+ // // Joining twice should succeed
+ // cmd1 := exec.Command("bash", "-c", `go run ../mattermost.go -join_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`" -email="`+th.BasicUser2.Email+`"`)
+ // output1, err1 := cmd1.CombinedOutput()
+ // if err1 != nil {
+ // t.Log(string(output1))
+ // t.Fatal(err1)
+ // }
+
+ // should fail because channel does not exist
+ cmd2 := exec.Command("bash", "-c", `go run ../mattermost.go -join_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`asdf" -email="`+th.BasicUser2.Email+`"`)
+ output2, err2 := cmd2.CombinedOutput()
+ if err2 == nil {
+ t.Log(string(output2))
+ t.Fatal()
+ }
+
+ // should fail because channel does not have license
+ cmd3 := exec.Command("bash", "-c", `go run ../mattermost.go -join_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`" -email="`+th.BasicUser2.Email+`"`)
+ output3, err3 := cmd3.CombinedOutput()
+ if err3 == nil {
+ t.Log(string(output3))
+ t.Fatal()
+ }
+}
+
+func TestCliRemoveChannel(t *testing.T) {
+ if disableCliTests {
+ return
+ }
+
+ th := Setup().InitBasic()
+ channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
+
+ // These test cannot run since this feature requires an enteprise license
+
+ // cmd := exec.Command("bash", "-c", `go run ../mattermost.go -join_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`" -email="`+th.BasicUser2.Email+`"`)
+ // output, err := cmd.CombinedOutput()
+ // if err != nil {
+ // t.Log(string(output))
+ // t.Fatal(err)
+ // }
+
+ // cmd0 := exec.Command("bash", "-c", `go run ../mattermost.go -leave_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`" -email="`+th.BasicUser2.Email+`"`)
+ // output0, err0 := cmd0.CombinedOutput()
+ // if err0 != nil {
+ // t.Log(string(output0))
+ // t.Fatal(err0)
+ // }
+
+ // // Leaving twice should succeed
+ // cmd1 := exec.Command("bash", "-c", `go run ../mattermost.go -leave_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`" -email="`+th.BasicUser2.Email+`"`)
+ // output1, err1 := cmd1.CombinedOutput()
+ // if err1 != nil {
+ // t.Log(string(output1))
+ // t.Fatal(err1)
+ // }
+
+ // cannot leave town-square
+ cmd1a := exec.Command("bash", "-c", `go run ../mattermost.go -leave_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="town-square" -email="`+th.BasicUser2.Email+`"`)
+ output1a, err1a := cmd1a.CombinedOutput()
+ if err1a == nil {
+ t.Log(string(output1a))
+ t.Fatal()
+ }
+
+ // should fail because channel does not exist
+ cmd2 := exec.Command("bash", "-c", `go run ../mattermost.go -leave_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`asdf" -email="`+th.BasicUser2.Email+`"`)
+ output2, err2 := cmd2.CombinedOutput()
+ if err2 == nil {
+ t.Log(string(output2))
+ t.Fatal()
+ }
+
+ // should fail because channel does not have license
+ cmd3 := exec.Command("bash", "-c", `go run ../mattermost.go -leave_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`" -email="`+th.BasicUser2.Email+`"`)
+ output3, err3 := cmd3.CombinedOutput()
+ if err3 == nil {
+ t.Log(string(output3))
+ t.Fatal()
+ }
+}
+
+func TestCliListChannels(t *testing.T) {
+ if disableCliTests {
+ return
+ }
+
+ th := Setup().InitBasic()
+ channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
+ th.BasicClient.Must(th.BasicClient.DeleteChannel(channel.Id))
+
+ // These test cannot run since this feature requires an enteprise license
+
+ // cmd := exec.Command("bash", "-c", `go run ../mattermost.go -list_channels -team_name="`+th.BasicTeam.Name+`"`)
+ // output, err := cmd.CombinedOutput()
+ // if err != nil {
+ // t.Log(string(output))
+ // t.Fatal(err)
+ // }
+
+ // if !strings.Contains(string(output), "town-square") {
+ // t.Fatal("should have channels")
+ // }
+
+ // if !strings.Contains(string(output), channel.Name+" (archived)") {
+ // t.Fatal("should have archived channel")
+ // }
+
+ // should fail because channel does not have license
+ cmd3 := exec.Command("bash", "-c", `go run ../mattermost.go -list_channels -team_name="`+th.BasicTeam.Name+``)
+ output3, err3 := cmd3.CombinedOutput()
+ if err3 == nil {
+ t.Log(string(output3))
+ t.Fatal()
+ }
+}
+
+func TestCliRestoreChannel(t *testing.T) {
+ if disableCliTests {
+ return
+ }
+
+ th := Setup().InitBasic()
+ channel := th.CreateChannel(th.BasicClient, th.BasicTeam)
+ th.BasicClient.Must(th.BasicClient.DeleteChannel(channel.Id))
+
+ // These test cannot run since this feature requires an enteprise license
+
+ // cmd := exec.Command("bash", "-c", `go run ../mattermost.go -restore_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`"`)
+ // output, err := cmd.CombinedOutput()
+ // if err != nil {
+ // t.Log(string(output))
+ // t.Fatal(err)
+ // }
+
+ // // restoring twice should succeed
+ // cmd1 := exec.Command("bash", "-c", `go run ../mattermost.go -restore_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`"`)
+ // output1, err1 := cmd1.CombinedOutput()
+ // if err1 != nil {
+ // t.Log(string(output1))
+ // t.Fatal(err1)
+ // }
+
+ // should fail because channel does not have license
+ cmd3 := exec.Command("bash", "-c", `go run ../mattermost.go -restore_channel -team_name="`+th.BasicTeam.Name+`" -channel_name="`+channel.Name+`"`)
+ output3, err3 := cmd3.CombinedOutput()
+ if err3 == nil {
+ t.Log(string(output3))
+ t.Fatal()
+ }
+}
+
func TestCliJoinTeam(t *testing.T) {
if disableCliTests {
return