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

--other=add unit test for polaris routing module #44

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

smartboyjia
Copy link

unit test add

Copy link

github-actions bot commented Jun 11, 2024

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@smartboyjia
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

liuzengh added a commit to trpc-group/cla-database that referenced this pull request Jun 11, 2024
Copy link

codecov bot commented Jun 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.62508%. Comparing base (e72139d) to head (4c5e1fc).

Current head 4c5e1fc differs from pull request most recent head 9fcc6c3

Please upload reports for the commit 9fcc6c3 to get more accurate results.

Additional details and impacted files

Impacted file tree graph

@@                  Coverage Diff                  @@
##                master         #44         +/-   ##
=====================================================
+ Coverage     69.41646%   69.62508%   +0.20861%     
- Complexity        4125        4139         +14     
=====================================================
  Files              428         428                 
  Lines            16777       16777                 
  Branches          1698        1698                 
=====================================================
+ Hits             11646       11681         +35     
+ Misses            4030        4000         -30     
+ Partials          1101        1096          -5     

see 6 files with indirect coverage changes

@smartboyjia smartboyjia changed the title --other=北极星路由模块用例添加 --other=add unit test for polaris routing module Jun 14, 2024
import java.util.List;
import java.util.Map;

import java.util.*;
Copy link
Collaborator

Choose a reason for hiding this comment

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

不能引入”*“,import具体的类

try {
clusterNaming.warmup(serviceId);
} catch (Exception e) {
return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

可以再这里断言一下,如果是测试异常情况,其他地方也是

}

@Test
public void testExceptionAsyncSelectAll() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

异常测试,需要断言一下,其他也是

request.getMeta().setHashVal("123333");
CompletionStage<ServiceInstance> future = clusterNaming.asyncSelectOne(serviceId, request);
AtomicReference<Throwable> errorRef = new AtomicReference<>();
CompletionStage<ServiceInstance> stage = future.whenComplete((res, err) -> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

能正常获取到实例,就没有异常吧,也可以判断一下ServiceInstance

when(instance.isHealthy()).thenReturn(true);
when(instance.getRevision()).thenReturn("1.0.0");
Map<String, String> metadata = new HashMap<>();
metadata.put("set", "set.sz.1");
Copy link
Collaborator

Choose a reason for hiding this comment

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

这些字符串和魔数辛苦提取为常量

try {
PolarisTrans.parseRouterResult(null,null);
} catch (Exception e) {
return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

缺少断言

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.

2 participants