Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
R
RoboPLC
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄新宇
RoboPLC
Commits
f99d3317
提交
f99d3317
authored
3月 07, 2024
作者:
Serhij S
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimized insta tests
上级
2cbe39c4
隐藏空白字符变更
内嵌
并排
正在显示
23 个修改的文件
包含
45 行增加
和
411 行删除
+45
-411
hub.rs
src/hub.rs
+2
-2
hub_async.rs
src/hub_async.rs
+2
-2
pchannel.rs
src/pchannel.rs
+3
-7
pchannel_async.rs
src/pchannel_async.rs
+3
-7
roboplc__hub__test__hub-2.snap
src/snapshots/roboplc__hub__test__hub-2.snap
+0
-42
roboplc__hub__test__hub.snap
src/snapshots/roboplc__hub__test__hub.snap
+0
-5
roboplc__hub_async__test__hub-2.snap
src/snapshots/roboplc__hub_async__test__hub-2.snap
+0
-42
roboplc__hub_async__test__hub.snap
src/snapshots/roboplc__hub_async__test__hub.snap
+0
-5
roboplc__pchannel__test__delivery_policy_optional-2.snap
.../roboplc__pchannel__test__delivery_policy_optional-2.snap
+0
-66
roboplc__pchannel__test__delivery_policy_optional.snap
...ts/roboplc__pchannel__test__delivery_policy_optional.snap
+0
-5
roboplc__pchannel__test__delivery_policy_single-2.snap
...ts/roboplc__pchannel__test__delivery_policy_single-2.snap
+0
-5
roboplc__pchannel__test__delivery_policy_single-3.snap
...ts/roboplc__pchannel__test__delivery_policy_single-3.snap
+0
-49
roboplc__pchannel__test__delivery_policy_single.snap
...hots/roboplc__pchannel__test__delivery_policy_single.snap
+0
-5
roboplc__pchannel_async__test__delivery_policy_optional-2.snap
...lc__pchannel_async__test__delivery_policy_optional-2.snap
+0
-66
roboplc__pchannel_async__test__delivery_policy_optional.snap
...oplc__pchannel_async__test__delivery_policy_optional.snap
+0
-5
roboplc__pchannel_async__test__delivery_policy_single-2.snap
...oplc__pchannel_async__test__delivery_policy_single-2.snap
+0
-5
roboplc__pchannel_async__test__delivery_policy_single-3.snap
...oplc__pchannel_async__test__delivery_policy_single-3.snap
+0
-49
roboplc__pchannel_async__test__delivery_policy_single.snap
...oboplc__pchannel_async__test__delivery_policy_single.snap
+0
-5
roboplc__ttlcell__test__get_set-2.snap
src/snapshots/roboplc__ttlcell__test__get_set-2.snap
+0
-5
roboplc__ttlcell__test__get_set-3.snap
src/snapshots/roboplc__ttlcell__test__get_set-3.snap
+0
-7
roboplc__ttlcell__test__get_set-4.snap
src/snapshots/roboplc__ttlcell__test__get_set-4.snap
+0
-5
roboplc__ttlcell__test__get_set.snap
src/snapshots/roboplc__ttlcell__test__get_set.snap
+0
-7
ttlcell.rs
src/ttlcell.rs
+35
-15
没有找到文件。
src/hub.rs
浏览文件 @
f99d3317
...
@@ -326,7 +326,7 @@ mod test {
...
@@ -326,7 +326,7 @@ mod test {
event_matches!
(
Message
::
Temperature
(
_
)
|
Message
::
Humidity
(
_
)),
event_matches!
(
Message
::
Temperature
(
_
)
|
Message
::
Humidity
(
_
)),
)
)
.unwrap
();
.unwrap
();
for
_
in
0
..
10
{
for
_
in
0
..
3
{
sender
.send
(
Message
::
Temperature
(
1.0
));
sender
.send
(
Message
::
Temperature
(
1.0
));
sender
.send
(
Message
::
Humidity
(
2.0
));
sender
.send
(
Message
::
Humidity
(
2.0
));
sender
.send
(
Message
::
Test
);
sender
.send
(
Message
::
Test
);
...
@@ -335,7 +335,7 @@ mod test {
...
@@ -335,7 +335,7 @@ mod test {
while
let
Ok
(
msg
)
=
recv
.try_recv
()
{
while
let
Ok
(
msg
)
=
recv
.try_recv
()
{
messages
.push
(
msg
);
messages
.push
(
msg
);
}
}
insta
::
assert_snapshot!
(
messages
.len
());
insta
::
assert_snapshot!
(
messages
.len
()
,
@
"6"
);
insta
::
assert_debug_snapshot!
(
messages
);
insta
::
assert_debug_snapshot!
(
messages
);
}
}
}
}
src/hub_async.rs
浏览文件 @
f99d3317
...
@@ -325,7 +325,7 @@ mod test {
...
@@ -325,7 +325,7 @@ mod test {
event_matches!
(
Message
::
Temperature
(
_
)
|
Message
::
Humidity
(
_
)),
event_matches!
(
Message
::
Temperature
(
_
)
|
Message
::
Humidity
(
_
)),
)
)
.unwrap
();
.unwrap
();
for
_
in
0
..
10
{
for
_
in
0
..
3
{
sender
.send
(
Message
::
Temperature
(
1.0
))
.await
;
sender
.send
(
Message
::
Temperature
(
1.0
))
.await
;
sender
.send
(
Message
::
Humidity
(
2.0
))
.await
;
sender
.send
(
Message
::
Humidity
(
2.0
))
.await
;
sender
.send
(
Message
::
Test
)
.await
;
sender
.send
(
Message
::
Test
)
.await
;
...
@@ -334,7 +334,7 @@ mod test {
...
@@ -334,7 +334,7 @@ mod test {
while
let
Ok
(
msg
)
=
client1
.try_recv
()
{
while
let
Ok
(
msg
)
=
client1
.try_recv
()
{
messages
.push
(
msg
);
messages
.push
(
msg
);
}
}
insta
::
assert_snapshot!
(
messages
.len
());
insta
::
assert_snapshot!
(
messages
.len
()
,
@
"6"
);
insta
::
assert_debug_snapshot!
(
messages
);
insta
::
assert_debug_snapshot!
(
messages
);
}
}
}
}
src/pchannel.rs
浏览文件 @
f99d3317
...
@@ -333,8 +333,7 @@ mod test {
...
@@ -333,8 +333,7 @@ mod test {
}
}
messages
.push
(
msg
);
messages
.push
(
msg
);
}
}
insta
::
assert_debug_snapshot!
(
messages
.len
());
insta
::
assert_debug_snapshot!
(
messages
.len
(),
@
"20"
);
insta
::
assert_debug_snapshot!
(
messages
);
}
}
#[test]
#[test]
...
@@ -352,18 +351,15 @@ mod test {
...
@@ -352,18 +351,15 @@ mod test {
thread
::
sleep
(
Duration
::
from_secs
(
1
));
thread
::
sleep
(
Duration
::
from_secs
(
1
));
let
mut
c
=
0
;
let
mut
c
=
0
;
let
mut
t
=
0
;
let
mut
t
=
0
;
let
mut
messages
=
Vec
::
new
();
while
let
Ok
(
msg
)
=
rx
.recv
()
{
while
let
Ok
(
msg
)
=
rx
.recv
()
{
match
msg
{
match
msg
{
Message
::
Test
(
_
)
=>
c
+=
1
,
Message
::
Test
(
_
)
=>
c
+=
1
,
Message
::
Temperature
(
_
)
=>
t
+=
1
,
Message
::
Temperature
(
_
)
=>
t
+=
1
,
Message
::
Spam
=>
{}
Message
::
Spam
=>
{}
}
}
messages
.push
(
msg
);
}
}
insta
::
assert_snapshot!
(
c
);
insta
::
assert_snapshot!
(
c
,
@
"10"
);
insta
::
assert_snapshot!
(
t
);
insta
::
assert_snapshot!
(
t
,
@
"1"
);
insta
::
assert_debug_snapshot!
(
messages
);
}
}
#[test]
#[test]
...
...
src/pchannel_async.rs
浏览文件 @
f99d3317
...
@@ -498,8 +498,7 @@ mod test {
...
@@ -498,8 +498,7 @@ mod test {
}
}
messages
.push
(
msg
);
messages
.push
(
msg
);
}
}
insta
::
assert_debug_snapshot!
(
messages
.len
());
insta
::
assert_debug_snapshot!
(
messages
.len
(),
@
"20"
);
insta
::
assert_debug_snapshot!
(
messages
);
}
}
#[tokio
::
test]
#[tokio
::
test]
...
@@ -517,18 +516,15 @@ mod test {
...
@@ -517,18 +516,15 @@ mod test {
thread
::
sleep
(
Duration
::
from_secs
(
1
));
thread
::
sleep
(
Duration
::
from_secs
(
1
));
let
mut
c
=
0
;
let
mut
c
=
0
;
let
mut
t
=
0
;
let
mut
t
=
0
;
let
mut
messages
=
Vec
::
new
();
while
let
Ok
(
msg
)
=
rx
.recv
()
.await
{
while
let
Ok
(
msg
)
=
rx
.recv
()
.await
{
match
msg
{
match
msg
{
Message
::
Test
(
_
)
=>
c
+=
1
,
Message
::
Test
(
_
)
=>
c
+=
1
,
Message
::
Temperature
(
_
)
=>
t
+=
1
,
Message
::
Temperature
(
_
)
=>
t
+=
1
,
Message
::
Spam
=>
{}
Message
::
Spam
=>
{}
}
}
messages
.push
(
msg
);
}
}
insta
::
assert_snapshot!
(
c
);
insta
::
assert_snapshot!
(
c
,
@
"10"
);
insta
::
assert_snapshot!
(
t
);
insta
::
assert_snapshot!
(
t
,
@
"1"
);
insta
::
assert_debug_snapshot!
(
messages
);
}
}
#[tokio
::
test]
#[tokio
::
test]
...
...
src/snapshots/roboplc__hub__test__hub-2.snap
浏览文件 @
f99d3317
...
@@ -21,46 +21,4 @@ expression: messages
...
@@ -21,46 +21,4 @@ expression: messages
Humidity(
Humidity(
2.0,
2.0,
),
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
]
]
src/snapshots/roboplc__hub__test__hub.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/hub.rs
expression: messages.len()
---
20
src/snapshots/roboplc__hub_async__test__hub-2.snap
浏览文件 @
f99d3317
...
@@ -21,46 +21,4 @@ expression: messages
...
@@ -21,46 +21,4 @@ expression: messages
Humidity(
Humidity(
2.0,
2.0,
),
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
Temperature(
1.0,
),
Humidity(
2.0,
),
]
]
src/snapshots/roboplc__hub_async__test__hub.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/hub_async.rs
expression: messages.len()
---
20
src/snapshots/roboplc__pchannel__test__delivery_policy_optional-2.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/pchannel.rs
expression: messages
---
[
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
]
src/snapshots/roboplc__pchannel__test__delivery_policy_optional.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/pchannel.rs
expression: messages.len()
---
20
src/snapshots/roboplc__pchannel__test__delivery_policy_single-2.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/pchannel.rs
expression: t
---
1
src/snapshots/roboplc__pchannel__test__delivery_policy_single-3.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/pchannel.rs
expression: messages
---
[
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Temperature(
123.0,
),
]
src/snapshots/roboplc__pchannel__test__delivery_policy_single.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/pchannel.rs
expression: c
---
10
src/snapshots/roboplc__pchannel_async__test__delivery_policy_optional-2.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/pchannel_async.rs
expression: messages
---
[
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
Test(
123,
),
Temperature(
123.0,
),
]
src/snapshots/roboplc__pchannel_async__test__delivery_policy_optional.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/pchannel_async.rs
expression: messages.len()
---
20
src/snapshots/roboplc__pchannel_async__test__delivery_policy_single-2.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/pchannel_async.rs
expression: t
---
1
src/snapshots/roboplc__pchannel_async__test__delivery_policy_single-3.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/pchannel_async.rs
expression: messages
---
[
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Test(
123,
),
Spam,
Temperature(
123.0,
),
]
src/snapshots/roboplc__pchannel_async__test__delivery_policy_single.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/pchannel_async.rs
expression: c
---
10
src/snapshots/roboplc__ttlcell__test__get_set-2.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/ttlcell.rs
expression: opt.as_ref().copied()
---
None
src/snapshots/roboplc__ttlcell__test__get_set-3.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/ttlcell.rs
expression: opt.as_ref().copied()
---
Some(
30,
)
src/snapshots/roboplc__ttlcell__test__get_set-4.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/ttlcell.rs
expression: opt.as_ref().copied()
---
None
src/snapshots/roboplc__ttlcell__test__get_set.snap
deleted
100644 → 0
浏览文件 @
2cbe39c4
---
source: src/ttlcell.rs
expression: opt.as_ref().copied()
---
Some(
25,
)
src/ttlcell.rs
浏览文件 @
f99d3317
...
@@ -146,42 +146,62 @@ mod test {
...
@@ -146,42 +146,62 @@ mod test {
let
ttl
=
Duration
::
from_millis
(
10
);
let
ttl
=
Duration
::
from_millis
(
10
);
let
mut
opt
=
TtlCell
::
new_with_value
(
ttl
,
25
);
let
mut
opt
=
TtlCell
::
new_with_value
(
ttl
,
25
);
thread
::
sleep
(
ttl
/
2
);
thread
::
sleep
(
ttl
/
2
);
insta
::
assert_debug_snapshot!
(
opt
.as_ref
()
.copied
());
insta
::
assert_debug_snapshot!
(
opt
.as_ref
()
.copied
(),
@
r
###
"
Some(
25,
)
"
###
);
thread
::
sleep
(
ttl
);
thread
::
sleep
(
ttl
);
insta
::
assert_debug_snapshot!
(
opt
.as_ref
()
.copied
());
insta
::
assert_debug_snapshot!
(
opt
.as_ref
()
.copied
()
,
@
"None"
);
opt
.set
(
30
);
opt
.set
(
30
);
thread
::
sleep
(
ttl
/
2
);
thread
::
sleep
(
ttl
/
2
);
insta
::
assert_debug_snapshot!
(
opt
.as_ref
()
.copied
());
insta
::
assert_debug_snapshot!
(
opt
.as_ref
()
.copied
(),
@
r
###
"
Some(
30,
)
"
###
);
thread
::
sleep
(
ttl
);
thread
::
sleep
(
ttl
);
insta
::
assert_debug_snapshot!
(
opt
.as_ref
()
.copied
());
insta
::
assert_debug_snapshot!
(
opt
.as_ref
()
.copied
()
,
@
"None"
);
}
}
#[test]
#[test]
fn
test_take_replace
()
{
fn
test_take_replace
()
{
let
ttl
=
Duration
::
from_millis
(
10
);
let
ttl
=
Duration
::
from_millis
(
10
);
let
mut
opt
=
TtlCell
::
new_with_value
(
ttl
,
25
);
let
mut
opt
=
TtlCell
::
new_with_value
(
ttl
,
25
);
thread
::
sleep
(
ttl
/
2
);
thread
::
sleep
(
ttl
/
2
);
assert_eq!
(
opt
.take
(),
Some
(
25
));
insta
::
assert_debug_snapshot!
(
opt
.take
(),
@
r
###
"
assert_eq!
(
opt
.as_ref
()
.copied
(),
None
);
Some(
25,
)
"
###
);
insta
::
assert_debug_snapshot!
(
opt
.as_ref
()
.copied
(),
@
"None"
);
opt
.set
(
30
);
opt
.set
(
30
);
thread
::
sleep
(
ttl
/
2
);
thread
::
sleep
(
ttl
/
2
);
assert_eq!
(
opt
.replace
(
29
),
Some
(
30
));
insta
::
assert_debug_snapshot!
(
opt
.replace
(
29
),
@
r
###
"
assert_eq!
(
opt
.as_ref
()
.copied
(),
Some
(
29
));
Some(
30,
)
"
###
);
thread
::
sleep
(
ttl
);
thread
::
sleep
(
ttl
);
assert_eq!
(
opt
.as_ref
()
.copied
(),
None
);
insta
::
assert_debug_snapshot!
(
opt
.as_ref
()
.copied
(),
@
"None"
);
}
}
#[test]
#[test]
fn
test_take_with
()
{
fn
test_take_with
()
{
let
mut
first
=
TtlCell
::
new_with_value
(
Duration
::
from_secs
(
1
),
25
);
let
mut
first
=
TtlCell
::
new_with_value
(
Duration
::
from_secs
(
1
),
25
);
thread
::
sleep
(
Duration
::
from_millis
(
10
));
thread
::
sleep
(
Duration
::
from_millis
(
10
));
let
mut
second
=
TtlCell
::
new_with_value
(
Duration
::
from_secs
(
1
),
25
);
let
mut
second
=
TtlCell
::
new_with_value
(
Duration
::
from_secs
(
1
),
25
);
assert
!
(
first
insta
::
assert_debug_snapshot!
(
first
.take_with
(
&
mut
second
,
Duration
::
from_millis
(
100
))
.take_with
(
&
mut
second
,
Duration
::
from_millis
(
100
)),
@
r
###
"
.is_some
());
Some(
(
25,
25,
),
)
"
###
);
let
mut
first
=
TtlCell
::
new_with_value
(
Duration
::
from_secs
(
1
),
25
);
let
mut
first
=
TtlCell
::
new_with_value
(
Duration
::
from_secs
(
1
),
25
);
thread
::
sleep
(
Duration
::
from_millis
(
100
));
thread
::
sleep
(
Duration
::
from_millis
(
100
));
let
mut
second
=
TtlCell
::
new_with_value
(
Duration
::
from_secs
(
1
),
25
);
let
mut
second
=
TtlCell
::
new_with_value
(
Duration
::
from_secs
(
1
),
25
);
assert
!
(
first
insta
::
assert_debug_snapshot!
(
.take_with
(
&
mut
second
,
Duration
::
from_millis
(
50
))
first
.take_with
(
&
mut
second
,
Duration
::
from_millis
(
50
)),
@
"None"
);
.is_none
());
}
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论