|
10 | 10 | import java.time.Duration; |
11 | 11 | import java.util.Date; |
12 | 12 |
|
13 | | -import static org.hamcrest.CoreMatchers.*; |
| 13 | +import static org.hamcrest.Matchers.*; |
14 | 14 | import static org.hamcrest.core.IsInstanceOf.instanceOf; |
15 | 15 |
|
16 | 16 | /** |
@@ -163,16 +163,20 @@ private void verifyRateLimitValues(GHRateLimit previousLimit, int remaining) { |
163 | 163 | } |
164 | 164 |
|
165 | 165 | private void verifyRateLimitValues(GHRateLimit previousLimit, int remaining, boolean changedResetDate) { |
166 | | - // newer or unchange |
167 | | - int resetComparisionValue = changedResetDate ? 1 : 0; |
168 | | - |
169 | 166 | // Basic checks of values |
170 | 167 | assertThat(rateLimit, notNullValue()); |
171 | 168 | assertThat(rateLimit.getLimit(), equalTo(previousLimit.getLimit())); |
172 | 169 | assertThat(rateLimit.getRemaining(), equalTo(remaining)); |
173 | 170 |
|
174 | 171 | // Check that the reset date of the current limit is not older than the previous one |
175 | | - assertThat(rateLimit.getResetDate().compareTo(previousLimit.getResetDate()), equalTo(resetComparisionValue)); |
| 172 | + long diffMillis = rateLimit.getResetDate().getTime() - previousLimit.getResetDate().getTime(); |
| 173 | + |
| 174 | + assertThat(diffMillis, greaterThanOrEqualTo(0L)); |
| 175 | + if (changedResetDate) { |
| 176 | + assertThat(diffMillis, greaterThan(1000L)); |
| 177 | + } else { |
| 178 | + assertThat(diffMillis, lessThanOrEqualTo(1000L)); |
| 179 | + } |
176 | 180 |
|
177 | 181 | // Additional checks for record values |
178 | 182 | assertThat(rateLimit.getCore().getLimit(), equalTo(rateLimit.getLimit())); |
|
0 commit comments