Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
4589a823
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
4589a823
编写于
6月 15, 2010
作者:
P
Pieter Noordhuis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
initial basic pub/sub tests
上级
676740a9
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
1 deletion
+47
-1
tests/support/redis.tcl
tests/support/redis.tcl
+1
-1
tests/test_helper.tcl
tests/test_helper.tcl
+1
-0
tests/unit/pubsub.tcl
tests/unit/pubsub.tcl
+45
-0
未找到文件。
tests/support/redis.tcl
浏览文件 @
4589a823
...
...
@@ -41,7 +41,7 @@ array set ::redis::multibulkarg {}
# Flag commands requiring last argument as a bulk write operation
foreach redis_bulk_cmd
{
set setnx rpush lpush rpushx lpushx linsert lset lrem sadd srem sismember echo getset smove zadd zrem zscore zincrby append zrank zrevrank hget hdel hexists setex
set setnx rpush lpush rpushx lpushx linsert lset lrem sadd srem sismember echo getset smove zadd zrem zscore zincrby append zrank zrevrank hget hdel hexists setex
publish
}
{
set ::redis::bulkarg
(
$redis
_bulk_cmd
)
{}
}
...
...
tests/test_helper.tcl
浏览文件 @
4589a823
...
...
@@ -88,6 +88,7 @@ proc main {} {
execute_tests
"unit/cas"
execute_tests
"integration/replication"
execute_tests
"integration/aof"
execute_tests
"unit/pubsub"
# run tests with VM enabled
set ::global_overrides
{
vm-enabled yes
}
...
...
tests/unit/pubsub.tcl
0 → 100644
浏览文件 @
4589a823
start_server
{
tags
{
"pubsub"
}}
{
test
"PUBLISH when no one is listening"
{
assert_equal 0
[
r publish chan hello
]
}
test
"SUBSCRIBE basics"
{
set rd1
[
redis_deferring_client
]
set rd2
[
redis_deferring_client
]
# subscribe first client to two channels
$rd1 subscribe chan1 chan2
assert_equal
{
subscribe chan1 1
}
[
$rd1
read
]
assert_equal
{
subscribe chan2 2
}
[
$rd1
read
]
# publish on both channels
assert_equal 1
[
r publish chan1 hello
]
assert_equal 1
[
r publish chan2 world
]
assert_equal
{
message chan1 hello
}
[
$rd1
read
]
assert_equal
{
message chan2 world
}
[
$rd1
read
]
# subscribe second client to one channel
$rd2 subscribe chan1
assert_equal
{
subscribe chan1 1
}
[
$rd2
read
]
# publish on channel with two subscribers
assert_equal 2
[
r publish chan1 hello
]
assert_equal
{
message chan1 hello
}
[
$rd1
read
]
assert_equal
{
message chan1 hello
}
[
$rd2
read
]
# unsubscribe first client from all channels
$rd1 unsubscribe
set msg
[
$rd1
read
]
assert_equal
"unsubscribe"
[
lindex $msg 0
]
assert_match
"chan*"
[
lindex $msg 1
]
assert_match 1
[
lindex $msg 2
]
set msg
[
$rd1
read
]
assert_equal
"unsubscribe"
[
lindex $msg 0
]
assert_match
"chan*"
[
lindex $msg 1
]
assert_match 0
[
lindex $msg 2
]
# publish on channel with only remaining subscriber
assert_equal 1
[
r publish chan1 hello
]
assert_equal
{
message chan1 hello
}
[
$rd2
read
]
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录