Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
梦境迷离
Zio Redis
提交
b7d56c2f
Z
Zio Redis
项目概览
梦境迷离
/
Zio Redis
9 个月 前同步成功
通知
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 搜索 >>
未验证
提交
b7d56c2f
编写于
5月 30, 2023
作者:
S
sunLightLeaf
提交者:
GitHub
5月 30, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle empty bulk string (#835)
上级
ca531f1f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
6 deletion
+24
-6
modules/redis/src/main/scala/zio/redis/Output.scala
modules/redis/src/main/scala/zio/redis/Output.scala
+0
-1
modules/redis/src/test/scala/zio/redis/OutputSpec.scala
modules/redis/src/test/scala/zio/redis/OutputSpec.scala
+12
-1
modules/redis/src/test/scala/zio/redis/StringsSpec.scala
modules/redis/src/test/scala/zio/redis/StringsSpec.scala
+12
-4
未找到文件。
modules/redis/src/main/scala/zio/redis/Output.scala
浏览文件 @
b7d56c2f
...
...
@@ -251,7 +251,6 @@ object Output {
protected
def
tryDecode
(
respValue
:
RespValue
)
:
Option
[
A
]
=
respValue
match
{
case
RespValue
.
NullBulkString
|
RespValue
.
NullArray
=>
None
case
RespValue
.
BulkString
(
value
)
if
value
.
isEmpty
=>
None
case
other
=>
Some
(
output
.
tryDecode
(
other
))
}
}
...
...
modules/redis/src/test/scala/zio/redis/OutputSpec.scala
浏览文件 @
b7d56c2f
...
...
@@ -134,15 +134,26 @@ object OutputSpec extends BaseSpec {
}
),
suite
(
"optional"
)(
test
(
"extract
None
"
)
{
test
(
"extract
null bulk string
"
)
{
for
{
res
<-
ZIO
.
attempt
(
OptionalOutput
(
UnitOutput
).
unsafeDecode
(
RespValue
.
NullBulkString
))
}
yield
assert
(
res
)(
isNone
)
},
test
(
"extract null array"
)
{
for
{
res
<-
ZIO
.
attempt
(
OptionalOutput
(
ArbitraryOutput
[
String
]()).
unsafeDecode
(
RespValue
.
NullArray
))
}
yield
assert
(
res
)(
isNone
)
},
test
(
"extract some"
)
{
for
{
res
<-
ZIO
.
attempt
(
OptionalOutput
(
UnitOutput
).
unsafeDecode
(
RespValue
.
SimpleString
(
"OK"
)))
}
yield
assert
(
res
)(
isSome
(
isUnit
))
},
test
(
"extract empty bulk string"
)
{
for
{
res
<-
ZIO
.
attempt
(
OptionalOutput
(
ArbitraryOutput
[
String
]()).
unsafeDecode
(
RespValue
.
BulkString
(
Chunk
.
empty
)))
}
yield
assert
(
res
)(
isSome
(
equalTo
(
""
)))
}
),
suite
(
"scan"
)(
...
...
modules/redis/src/test/scala/zio/redis/StringsSpec.scala
浏览文件 @
b7d56c2f
...
...
@@ -982,13 +982,21 @@ trait StringsSpec extends BaseSpec {
result
<-
redis
.
get
(
key
).
returning
[
String
]
}
yield
assert
(
result
)(
isSome
(
equalTo
(
"value"
)))
},
test
(
"
emtpy
string"
)
{
test
(
"
non existent
string"
)
{
for
{
redis
<-
ZIO
.
service
[
Redis
]
key
<-
uuid
result
<-
redis
.
get
(
key
).
returning
[
String
]
}
yield
assert
(
result
)(
isNone
)
},
test
(
"empty string"
)
{
for
{
redis
<-
ZIO
.
service
[
Redis
]
key
<-
uuid
_
<-
redis
.
set
(
key
,
""
)
result
<-
redis
.
get
(
key
).
returning
[
String
]
}
yield
assert
(
result
)(
isSome
(
equalTo
(
""
)))
},
test
(
"error when not string"
)
{
for
{
redis
<-
ZIO
.
service
[
Redis
]
...
...
@@ -1061,7 +1069,7 @@ trait StringsSpec extends BaseSpec {
key
<-
uuid
_
<-
redis
.
set
(
key
,
"value"
)
substr
<-
redis
.
getRange
(
key
,
10
to
15
).
returning
[
String
]
}
yield
assert
(
substr
)(
is
None
)
}
yield
assert
(
substr
)(
is
Some
(
equalTo
(
""
))
)
},
test
(
"with inverse range of non-empty string"
)
{
for
{
...
...
@@ -1069,7 +1077,7 @@ trait StringsSpec extends BaseSpec {
key
<-
uuid
_
<-
redis
.
set
(
key
,
"value"
)
substr
<-
redis
.
getRange
(
key
,
15
to
3
).
returning
[
String
]
}
yield
assert
(
substr
)(
is
None
)
}
yield
assert
(
substr
)(
is
Some
(
equalTo
(
""
))
)
},
test
(
"with negative range end from non-empty string"
)
{
for
{
...
...
@@ -1092,7 +1100,7 @@ trait StringsSpec extends BaseSpec {
redis
<-
ZIO
.
service
[
Redis
]
key
<-
uuid
substr
<-
redis
.
getRange
(
key
,
1
to
3
).
returning
[
String
]
}
yield
assert
(
substr
)(
is
None
)
}
yield
assert
(
substr
)(
is
Some
(
equalTo
(
""
))
)
},
test
(
"error when not string"
)
{
for
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录