Skip to content

Commit d7e9879

Browse files
committed
Using specific channel type
1 parent b67ab11 commit d7e9879

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

channel_test.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -949,16 +949,11 @@ func ExampleChannel_Query() {
949949
func TestChannel_MessageCount_DefaultEnabled(t *testing.T) {
950950
c := initClient(t)
951951
ctx := context.Background()
952-
953-
_, err := c.UpdateChannelType(ctx, "team", map[string]interface{}{"count_messages": true})
954-
require.NoError(t, err)
955-
956-
time.Sleep(500 * time.Millisecond)
957-
ch := initChannel(t, c)
952+
ch := initChannelWithType(t, c, "message_counting")
958953

959954
// Send a single message to the channel
960955
user := randomUser(t, c)
961-
_, err = ch.SendMessage(ctx, &Message{Text: "hello world"}, user.ID)
956+
_, err := ch.SendMessage(ctx, &Message{Text: "hello world"}, user.ID)
962957
require.NoError(t, err, "send message")
963958

964959
// Refresh the channel state to get the updated message_count field
@@ -967,10 +962,6 @@ func TestChannel_MessageCount_DefaultEnabled(t *testing.T) {
967962
// message_count should be present and equal to 1
968963
require.NotNil(t, ch.MessageCount, "message_count should not be nil when CountMessages is enabled")
969964
assert.Equal(t, 1, *ch.MessageCount)
970-
971-
// Clean up: reset the CountMessages feature to false
972-
_, err = c.UpdateChannelType(ctx, "team", map[string]interface{}{"count_messages": false})
973-
require.NoError(t, err)
974965
}
975966

976967
// TestChannel_MessageCount_Disabled verifies that message_count is omitted when the

client_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ func initClient(t *testing.T) *Client {
2020
}
2121

2222
func initChannel(t *testing.T, c *Client, membersID ...string) *Channel {
23+
return initChannelWithType(t, c, "team", membersID...)
24+
}
25+
26+
func initChannelWithType(t *testing.T, c *Client, channelType string, membersID ...string) *Channel {
2327
t.Helper()
2428

2529
owner := randomUser(t, c)
2630
ctx := context.Background()
2731

28-
resp, err := c.CreateChannelWithMembers(ctx, "team", randomString(12), owner.ID, membersID...)
32+
resp, err := c.CreateChannelWithMembers(ctx, channelType, randomString(12), owner.ID, membersID...)
2933
require.NoError(t, err, "create channel")
3034

3135
t.Cleanup(func() {

0 commit comments

Comments
 (0)