Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Zio Redis
提交
adf31cc9
Z
Zio Redis
项目概览
梦境迷离
/
Zio Redis
8 个月 前同步成功
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
Zio Redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
adf31cc9
编写于
11月 30, 2020
作者:
L
Lachlan O'Dea
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Output tests.
上级
75e5a9cf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
100 addition
and
23 deletion
+100
-23
redis/src/main/scala/zio/redis/options/Connection.scala
redis/src/main/scala/zio/redis/options/Connection.scala
+23
-23
redis/src/test/scala/zio/redis/OutputSpec.scala
redis/src/test/scala/zio/redis/OutputSpec.scala
+77
-0
未找到文件。
redis/src/main/scala/zio/redis/options/Connection.scala
浏览文件 @
adf31cc9
...
...
@@ -58,32 +58,32 @@ trait Connection {
case
object
BroadcastTrackingMode
extends
ClientFlag
}
sealed
case
class
ClientEvents
(
readable
:
Boolean
,
writable
:
Boolean
)
sealed
case
class
ClientEvents
(
readable
:
Boolean
=
false
,
writable
:
Boolean
=
false
)
sealed
case
class
ClientInfo
(
id
:
Long
,
name
:
Option
[
String
],
address
:
Option
[
InetAddress
],
localAddress
:
Option
[
InetAddress
],
fileDescriptor
:
Option
[
Long
],
age
:
Option
[
Duration
],
idle
:
Option
[
Duration
],
flags
:
Set
[
ClientFlag
],
databaseId
:
Option
[
Long
],
subscriptions
:
Int
,
patternSubscriptions
:
Int
,
multiCommands
:
Int
,
queryBufferLength
:
Option
[
Int
],
queryBufferFree
:
Option
[
Int
],
outputBufferLength
:
Option
[
Int
],
outputListLength
:
Option
[
Int
],
outputBufferMem
:
Option
[
Long
],
events
:
ClientEvents
,
lastCommand
:
Option
[
String
],
argvMemory
:
Option
[
Long
],
totalMemory
:
Option
[
Long
],
redirectionClientId
:
Option
[
Long
],
user
:
Option
[
String
]
name
:
Option
[
String
]
=
None
,
address
:
Option
[
InetAddress
]
=
None
,
localAddress
:
Option
[
InetAddress
]
=
None
,
fileDescriptor
:
Option
[
Long
]
=
None
,
age
:
Option
[
Duration
]
=
None
,
idle
:
Option
[
Duration
]
=
None
,
flags
:
Set
[
ClientFlag
]
=
Set
.
empty
,
databaseId
:
Option
[
Long
]
=
None
,
subscriptions
:
Int
=
0
,
patternSubscriptions
:
Int
=
0
,
multiCommands
:
Int
=
0
,
queryBufferLength
:
Option
[
Int
]
=
None
,
queryBufferFree
:
Option
[
Int
]
=
None
,
outputBufferLength
:
Option
[
Int
]
=
None
,
outputListLength
:
Option
[
Int
]
=
None
,
outputBufferMem
:
Option
[
Long
]
=
None
,
events
:
ClientEvents
=
ClientEvents
()
,
lastCommand
:
Option
[
String
]
=
None
,
argvMemory
:
Option
[
Long
]
=
None
,
totalMemory
:
Option
[
Long
]
=
None
,
redirectionClientId
:
Option
[
Long
]
=
None
,
user
:
Option
[
String
]
=
None
)
sealed
abstract
class
ClientTrackingRedirect
...
...
redis/src/test/scala/zio/redis/OutputSpec.scala
浏览文件 @
adf31cc9
package
zio.redis
import
java.net.InetAddress
import
zio.duration._
import
zio.redis.Output._
import
zio.redis.RedisError._
...
...
@@ -17,6 +19,8 @@ object OutputSpec extends BaseSpec {
private
def
respArrayVals
(
xs
:
RespValue*
)
=
RespValue
.
Array
(
Chunk
.
fromIterable
(
xs
))
private
def
respInt
(
i
:
Long
)
=
RespValue
.
Integer
(
i
)
def
spec
=
suite
(
"Output decoders"
)(
suite
(
"errors"
)(
...
...
@@ -243,6 +247,79 @@ object OutputSpec extends BaseSpec {
res
<-
Task
(
ChunkOptionalLongOutput
.
unsafeDecode
(
input
))
}
yield
assert
(
res
)(
equalTo
(
Chunk
(
Some
(
1L
),
Some
(
1L
),
Some
(
2L
),
Some
(
3L
))))
}
),
suite
(
"ClientInfo"
)(
testM
(
"addresses"
)
{
val
id
=
42L
val
inetAddress
=
InetAddress
.
getByName
(
"127.0.0.1"
)
val
input
=
respBulkString
(
s
"addr=${inetAddress.getHostAddress} id=$id laddr=${inetAddress.getHostAddress}"
)
for
{
res
<-
Task
(
ClientInfoOutput
.
unsafeDecode
(
input
))
}
yield
assert
(
res
)(
equalTo
(
Chunk
.
single
(
ClientInfo
(
id
=
id
,
address
=
Some
(
inetAddress
),
localAddress
=
Some
(
inetAddress
))))
)
},
testM
(
"flags"
)
{
import
ClientFlag._
val
id
=
42L
val
input
=
respBulkString
(
s
"flags=bOPSRt id=$id"
)
val
expectedFlags
:
Set
[
ClientFlag
]
=
Set
(
Blocked
,
MonitorMode
,
PubSub
,
Replica
,
TrackingTargetClientInvalid
,
KeysTrackingEnabled
)
for
{
res
<-
Task
(
ClientInfoOutput
.
unsafeDecode
(
input
))
}
yield
assert
(
res
)(
equalTo
(
Chunk
.
single
(
ClientInfo
(
id
=
id
,
flags
=
expectedFlags
))))
},
testM
(
"ignores unknown flags"
)
{
val
id
=
42L
val
input
=
respBulkString
(
s
"flags=XYZ id=$id"
)
for
{
res
<-
Task
(
ClientInfoOutput
.
unsafeDecode
(
input
))
}
yield
assert
(
res
)(
equalTo
(
Chunk
.
single
(
ClientInfo
(
id
=
id
,
flags
=
Set
.
empty
))))
},
testM
(
"multiple"
)
{
val
input
=
respBulkString
(
s
"""sub=4 id=42 idle=6 fd=9234
|id=99 events=r db=33
|id=1 cmd=foo"""
.
stripMargin
)
for
{
res
<-
Task
(
ClientInfoOutput
.
unsafeDecode
(
input
))
}
yield
assert
(
res
)(
equalTo
(
Chunk
(
ClientInfo
(
id
=
42L
,
idle
=
Some
(
6.
seconds
),
subscriptions
=
4
,
fileDescriptor
=
Some
(
9234L
)),
ClientInfo
(
id
=
99
,
events
=
ClientEvents
(
readable
=
true
),
databaseId
=
Some
(
33L
)),
ClientInfo
(
id
=
1
,
lastCommand
=
Some
(
"foo"
))
)
)
)
}
),
suite
(
"ClientTrackingRedirect"
)(
testM
(
"Not enabled"
)
{
val
input
=
respInt
(-
1L
)
for
{
res
<-
Task
(
ClientTrackingRedirectOutput
.
unsafeDecode
(
input
))
}
yield
assert
(
res
)(
equalTo
(
ClientTrackingRedirect
.
NotEnabled
))
},
testM
(
"Not redirected"
)
{
val
input
=
respInt
(
0L
)
for
{
res
<-
Task
(
ClientTrackingRedirectOutput
.
unsafeDecode
(
input
))
}
yield
assert
(
res
)(
equalTo
(
ClientTrackingRedirect
.
NotRedirected
))
},
testM
(
"redirected"
)
{
val
input
=
respInt
(
42L
)
for
{
res
<-
Task
(
ClientTrackingRedirectOutput
.
unsafeDecode
(
input
))
}
yield
assert
(
res
)(
equalTo
(
ClientTrackingRedirect
.
RedirectedTo
(
input
.
value
)))
}
)
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录