-
Notifications
You must be signed in to change notification settings - Fork 117
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
Mention users with dash #2258
Mention users with dash #2258
Conversation
Tried testing it is impossible |
Codecov Report
@@ Coverage Diff @@
## develop #2258 +/- ##
=============================================
+ Coverage 56.55% 56.57% +0.02%
- Complexity 3771 3773 +2
=============================================
Files 520 520
Lines 19712 19712
Branches 1171 1171
=============================================
+ Hits 11149 11153 +4
+ Misses 7946 7943 -3
+ Partials 617 616 -1
Continue to review full report at Codecov.
|
Can’t you write some tests like I did on the issue. Make a Matcher and call find. What about users who’s name starts with a dash? |
Well the code does a shit tone of other things including reading files etc. and because we do not load a spring context this is incredible hard to mock away. Well I could just refactor to make it more testable I guess |
I stay with can not be tested |
Just test the regex. You don’t need to test the code that uses the regex. Just do something like assertTrue(CHAT_PATTERN.matcher("Hello Box-!").find(); Whatever the syntax is |
@@ -250,7 +250,7 @@ public void setReceiver(String receiver) { | |||
} | |||
|
|||
public void initialize() { | |||
mentionPattern = Pattern.compile("\\b(" + Pattern.quote(userService.getUsername()) + ")\\b", CASE_INSENSITIVE); | |||
mentionPattern = Pattern.compile("\\b(" + Pattern.quote(userService.getUsername()) + ")\\b|[ ]", CASE_INSENSITIVE); |
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.
Btw this doesn’t catch the case where the username is the only thing on the line. Like, this will not match the string "Box-".
This reverts commit 426b5a8.
This reverts commit 426b5a8.
Fixes #2202