Skip to content

Commit d09b4f5

Browse files
committed
Stabilize the tests
1 parent 8f17e2f commit d09b4f5

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

bolt/src/test/java/test_locally/app/MultiTeamsAuthTestCacheTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import com.slack.api.bolt.request.builtin.GlobalShortcutRequest;
1414
import com.slack.api.bolt.response.Response;
1515
import com.slack.api.bolt.service.InstallationService;
16+
import com.slack.api.methods.MethodsConfig;
1617
import com.slack.api.methods.SlackApiException;
1718
import lombok.extern.slf4j.Slf4j;
1819
import org.eclipse.jetty.server.Server;
@@ -43,6 +44,12 @@
4344
public class MultiTeamsAuthTestCacheTest {
4445

4546
static SlackConfig config = new SlackConfig();
47+
static {
48+
MethodsConfig methodsConfig = new MethodsConfig();
49+
methodsConfig.setStatsEnabled(false); // To skip TeamIdCache requests
50+
config.setMethodsConfig(methodsConfig);
51+
}
52+
4653
static Slack slack = Slack.getInstance(config);
4754
static CountdownAuthTestServer server = new CountdownAuthTestServer();
4855

@@ -192,7 +199,7 @@ public static class CountdownAuthTestMockEndpoint extends HttpServlet {
192199
@Override
193200
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
194201
String token = req.getHeader("Authorization").replaceFirst("Bearer ", "");
195-
int count = remaining.computeIfAbsent(token, (t) -> new AtomicInteger(2)).getAndDecrement();
202+
int count = remaining.computeIfAbsent(token, (t) -> new AtomicInteger(1)).getAndDecrement();
196203
if (count <= 0) {
197204
resp.setStatus(500);
198205
return;

bolt/src/test/java/test_locally/app/SingleTeamAuthTestCacheTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.slack.api.bolt.request.RequestHeaders;
99
import com.slack.api.bolt.request.builtin.GlobalShortcutRequest;
1010
import com.slack.api.bolt.response.Response;
11+
import com.slack.api.methods.MethodsConfig;
1112
import com.slack.api.methods.SlackApiException;
1213
import lombok.extern.slf4j.Slf4j;
1314
import org.eclipse.jetty.server.Server;
@@ -38,6 +39,11 @@
3839
public class SingleTeamAuthTestCacheTest {
3940

4041
static SlackConfig config = new SlackConfig();
42+
static {
43+
MethodsConfig methodsConfig = new MethodsConfig();
44+
methodsConfig.setStatsEnabled(false); // To skip TeamIdCache requests
45+
config.setMethodsConfig(methodsConfig);
46+
}
4147
static Slack slack = Slack.getInstance(config);
4248
static CountdownAuthTestServer server = new CountdownAuthTestServer();
4349

@@ -154,7 +160,7 @@ public static class CountdownAuthTestMockEndpoint extends HttpServlet {
154160
@Override
155161
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
156162
String token = req.getHeader("Authorization").replaceFirst("Bearer ", "");
157-
int count = remaining.computeIfAbsent(token, (t) -> new AtomicInteger(2)).getAndDecrement();
163+
int count = remaining.computeIfAbsent(token, (t) -> new AtomicInteger(1)).getAndDecrement();
158164
if (count <= 0) {
159165
resp.setStatus(500);
160166
return;

0 commit comments

Comments
 (0)