-
Notifications
You must be signed in to change notification settings - Fork 29
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
base: master
Are you sure you want to change the base?
--other=add unit test for polaris routing module #44
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ 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 |
import java.util.List; | ||
import java.util.Map; | ||
|
||
import java.util.*; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以再这里断言一下,如果是测试异常情况,其他地方也是
} | ||
|
||
@Test | ||
public void testExceptionAsyncSelectAll() { |
There was a problem hiding this comment.
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) -> { |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺少断言
unit test add