Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复由于毫秒数导致断言失败的问题 #491

Open
wants to merge 3 commits into
base: master-jdk17
Choose a base branch
from

Conversation

DevDengChao
Copy link
Contributor

No description provided.

@@ -114,7 +114,7 @@ public void testCleanJobLog() {
assertEquals(1, count);
List<JobLogDO> logs = jobLogMapper.selectList();
assertEquals(1, logs.size());
assertEquals(log02, logs.get(0));
assertPojoEquals(log02, logs.get(0),"createTime");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个我测试了下,貌似不加也没问题哈?

另外,在 , 有个空格,代码排版哈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

把 h2 的 createTime 改成 timestamp 类型并不能解决这个问题.

@@ -91,7 +91,7 @@ public void testCleanJobLog() {
assertEquals(1, count);
List<ApiAccessLogDO> logs = apiAccessLogMapper.selectList();
assertEquals(1, logs.size());
assertEquals(log02, logs.get(0));
assertPojoEquals(log02, logs.get(0), "createTime");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个我测试了下,貌似不加也没问题哈?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

貌似不加也没问题

🤣 莫非遇到玄学环境问题了.

@@ -157,7 +157,7 @@ public void testCleanJobLog() {
assertEquals(1, count);
List<ApiErrorLogDO> logs = apiErrorLogMapper.selectList();
assertEquals(1, logs.size());
assertEquals(log02, logs.get(0));
assertPojoEquals(log02, logs.get(0),"createTime");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个我测试了下,貌似不加也没问题哈?

@@ -355,9 +355,9 @@ public void testSubmitOrder_channelError() {
when(client.unifiedOrder(argThat(payOrderUnifiedReqDTO -> {
assertNotNull(payOrderUnifiedReqDTO.getOutTradeNo());
assertThat(payOrderUnifiedReqDTO)
.extracting("subject", "body", "notifyUrl", "returnUrl", "price", "expireTime")
.extracting("subject", "body", "notifyUrl", "returnUrl", "price")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是还是倾向,解决 expireTime 可以被比较哈?

OAuth2ApproveDO approve = randomPojo(OAuth2ApproveDO.class).setUserId(userId)
.setUserType(userType).setClientId(clientId).setExpiresTime(LocalDateTimeUtil.offset(LocalDateTime.now(), 1L, ChronoUnit.DAYS));
.setUserType(userType).setClientId(clientId).setExpiresTime(localDateTime);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以考虑把 h2 对应的字段,改成 timestamp,提供到 nanoseconds,这样更简单一点

@@ -251,7 +251,7 @@ public void testRemoveAccessToken_null() {
public void testRemoveAccessToken_success() {
// mock 数据(访问令牌)
OAuth2AccessTokenDO accessTokenDO = randomPojo(OAuth2AccessTokenDO.class)
.setExpiresTime(LocalDateTime.now().plusDays(1));
.setExpiresTime(LocalDateTime.now().plusDays(1).withNano(0));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以考虑把 h2 对应的字段,改成 timestamp,提供到 nanoseconds,这样更简单一点

@YunaiV
Copy link
Owner

YunaiV commented May 1, 2024

哈罗~我看已经改动完了。

是不是一些地方强制 nanoseconds 为 0,貌似可以去掉了哈。

@YunaiV
Copy link
Owner

YunaiV commented May 1, 2024

包括 createtime 忽略,是不是可以试试,不忽略哈。

@DevDengChao
Copy link
Contributor Author

我本地保留了 h2 数据库变更字段为 timestamp 的改动, 回退了之前单元测试里的改动, 然后跑单元测试不通过.

image

image

我本地的 JDK 用的是 Java(TM) SE Runtime Environment Oracle GraalVM 21+35.1 (build 21+35-jvmci-23.1-b15)

@DevDengChao
Copy link
Contributor Author

只修改 timestamp 并更换 JDK 成 Oracle 17.0.6 依然无法通过单元测试.

@YunaiV
Copy link
Owner

YunaiV commented May 9, 2024

方便加下 wangwenbin-server

我有点复现补出单测跑失败的情况

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants