@@ -19,48 +19,79 @@ func (suite *GlideTestSuite) TestPubSub_Commands_Channels() {
1919 channelNames []string
2020 pattern string
2121 expectedNames []string
22+ sharded bool
2223 }{
2324 {
2425 name : "Standalone Empty Pattern" ,
2526 clientType : GlideClient ,
2627 channelNames : []string {"news.sports" , "news.weather" , "events.local" },
2728 pattern : "" ,
2829 expectedNames : []string {"news.sports" , "news.weather" , "events.local" },
30+ sharded : false ,
2931 },
3032 {
3133 name : "Standalone Exact Match" ,
3234 clientType : GlideClient ,
3335 channelNames : []string {"news.sports" , "news.weather" , "events.local" },
3436 pattern : "news.sports" ,
3537 expectedNames : []string {"news.sports" },
38+ sharded : false ,
3639 },
3740 {
3841 name : "Standalone Glob Pattern" ,
3942 clientType : GlideClient ,
4043 channelNames : []string {"news.sports" , "news.weather" , "events.local" },
4144 pattern : "news.*" ,
4245 expectedNames : []string {"news.sports" , "news.weather" },
46+ sharded : false ,
4347 },
4448 {
4549 name : "Cluster Empty Pattern" ,
4650 clientType : GlideClusterClient ,
4751 channelNames : []string {"cluster.news.sports" , "cluster.news.weather" , "cluster.events.local" },
4852 pattern : "" ,
4953 expectedNames : []string {"cluster.news.sports" , "cluster.news.weather" , "cluster.events.local" },
54+ sharded : false ,
5055 },
5156 {
5257 name : "Cluster Exact Match" ,
5358 clientType : GlideClusterClient ,
5459 channelNames : []string {"cluster.news.sports" , "cluster.news.weather" , "cluster.events.local" },
5560 pattern : "cluster.news.sports" ,
5661 expectedNames : []string {"cluster.news.sports" },
62+ sharded : false ,
5763 },
5864 {
5965 name : "Cluster Glob Pattern" ,
6066 clientType : GlideClusterClient ,
6167 channelNames : []string {"cluster.news.sports" , "cluster.news.weather" , "cluster.events.local" },
6268 pattern : "cluster.news.*" ,
6369 expectedNames : []string {"cluster.news.sports" , "cluster.news.weather" },
70+ sharded : false ,
71+ },
72+ {
73+ name : "Cluster Sharded Empty Pattern" ,
74+ clientType : GlideClusterClient ,
75+ channelNames : []string {"cluster.shard.news.sports" , "cluster.shard.news.weather" , "cluster.shard.events.local" },
76+ pattern : "" ,
77+ expectedNames : []string {"cluster.shard.news.sports" , "cluster.shard.news.weather" , "cluster.shard.events.local" },
78+ sharded : true ,
79+ },
80+ {
81+ name : "Cluster Sharded Exact Match" ,
82+ clientType : GlideClusterClient ,
83+ channelNames : []string {"cluster.shard.news.sports" , "cluster.shard.news.weather" , "cluster.shard.events.local" },
84+ pattern : "cluster.shard.news.sports" ,
85+ expectedNames : []string {"cluster.shard.news.sports" },
86+ sharded : true ,
87+ },
88+ {
89+ name : "Cluster Sharded Glob Pattern" ,
90+ clientType : GlideClusterClient ,
91+ channelNames : []string {"cluster.shard.news.sports" , "cluster.shard.news.weather" , "cluster.shard.events.local" },
92+ pattern : "cluster.shard.news.*" ,
93+ expectedNames : []string {"cluster.shard.news.sports" , "cluster.shard.news.weather" },
94+ sharded : true ,
6495 },
6596 }
6697
@@ -69,7 +100,7 @@ func (suite *GlideTestSuite) TestPubSub_Commands_Channels() {
69100 // Create channel definitions for all channels
70101 channels := make ([]ChannelDefn , len (tt .channelNames ))
71102 for i , channelName := range tt .channelNames {
72- channels [i ] = ChannelDefn {Channel : channelName , Mode : 0 } // ExactMode
103+ channels [i ] = ChannelDefn {Channel : channelName , Mode : getChannelMode ( tt . sharded )}
73104 }
74105
75106 // Create a client with subscriptions
@@ -82,10 +113,23 @@ func (suite *GlideTestSuite) TestPubSub_Commands_Channels() {
82113 // Get active channels
83114 var activeChannels []string
84115 var err error
85- if tt .pattern == "" {
86- activeChannels , err = receiver .PubSubChannels ()
116+ if tt .sharded {
117+ // For sharded channels, we need to use the cluster-specific methods
118+ clusterClient , ok := receiver .(* api.GlideClusterClient )
119+ if ! ok {
120+ t .Fatal ("Expected GlideClusterClient for sharded channels" )
121+ }
122+ if tt .pattern == "" {
123+ activeChannels , err = clusterClient .PubSubShardChannels ()
124+ } else {
125+ activeChannels , err = clusterClient .PubSubShardChannelsWithPattern (tt .pattern )
126+ }
87127 } else {
88- activeChannels , err = receiver .PubSubChannelsWithPattern (tt .pattern )
128+ if tt .pattern == "" {
129+ activeChannels , err = receiver .PubSubChannels ()
130+ } else {
131+ activeChannels , err = receiver .PubSubChannelsWithPattern (tt .pattern )
132+ }
89133 }
90134 assert .NoError (t , err )
91135
0 commit comments