Expose GroupConstrained flag where needed and add tests (#10604)

This commit is contained in:
Miguel de la Cruz
2019-04-15 16:13:11 +01:00
committed by Jesús Espino
parent 5db62c20c5
commit 4c52f91997
3 changed files with 68 additions and 1 deletions

View File

@@ -139,6 +139,15 @@ func TestCreateChannel(t *testing.T) {
t.Fatal("wrong status code")
}
}
// Test GroupConstrained flag
groupConstrainedChannel := &model.Channel{DisplayName: "Test API Name", Name: GenerateTestChannelName(), Type: model.CHANNEL_OPEN, TeamId: team.Id, GroupConstrained: model.NewBool(true)}
rchannel, resp = Client.CreateChannel(groupConstrainedChannel)
CheckNoError(t, resp)
if *rchannel.GroupConstrained != *groupConstrainedChannel.GroupConstrained {
t.Fatal("GroupConstrained flags do not match")
}
}
func TestUpdateChannel(t *testing.T) {
@@ -173,6 +182,16 @@ func TestUpdateChannel(t *testing.T) {
t.Fatal("Update failed for Purpose")
}
// Test GroupConstrained flag
channel.GroupConstrained = model.NewBool(true)
rchannel, resp := Client.UpdateChannel(channel)
CheckNoError(t, resp)
CheckOKStatus(t, resp)
if *rchannel.GroupConstrained != *channel.GroupConstrained {
t.Fatal("GroupConstrained flags do not match")
}
//Update a private channel
private.DisplayName = "My new display name for private channel"
private.Header = "My fancy private header"
@@ -281,6 +300,17 @@ func TestPatchChannel(t *testing.T) {
t.Fatal("should not have updated")
}
// Test GroupConstrained flag
patch.GroupConstrained = model.NewBool(true)
rchannel, resp := Client.PatchChannel(th.BasicChannel.Id, patch)
CheckNoError(t, resp)
CheckOKStatus(t, resp)
if *rchannel.GroupConstrained != *patch.GroupConstrained {
t.Fatal("GroupConstrained flags do not match")
}
patch.GroupConstrained = nil
_, resp = Client.PatchChannel("junk", patch)
CheckBadRequestStatus(t, resp)