Skip to content

Commit

Permalink
⚡️ fix: 테스트에서의 SlackUtil 의존성 문제 해결 #4
Browse files Browse the repository at this point in the history
  • Loading branch information
jun02160 committed Jan 5, 2024
1 parent cc2faf5 commit 2bbf54e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ dependencies {
testImplementation 'org.awaitility:awaitility:4.2.0'

// Slack Webhook
implementation 'com.slack.api:slack-api-client:1.28.0'
implementation 'com.slack.api:slack-api-client:1.30.0'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
implementation 'com.slack.api:slack-app-backend:1.28.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package sopt.org.motivooServer.global.advice;

import static org.springframework.http.HttpStatus.*;
import static sopt.org.motivooServer.global.advice.ErrorType.INTERNAL_SERVER_ERROR;
import static sopt.org.motivooServer.global.advice.ErrorType.*;

import java.io.IOException;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

Expand All @@ -17,7 +15,6 @@
import sopt.org.motivooServer.global.util.slack.SlackUtil;

@Slf4j
@Component
@RequiredArgsConstructor
@RestControllerAdvice
public class GlobalExceptionHandler {
Expand All @@ -35,6 +32,8 @@ public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class)
public ResponseEntity<ErrorResponse> handleException(final Exception e, final HttpServletRequest request) throws IOException {
slackUtil.sendAlert(e, request);

log.error("🔔🚨 Slack에 전송된 Error Log: {}", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body(ErrorResponse.of(INTERNAL_SERVER_ERROR));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public class SlackUtil {
private final static String NEW_LINE = "\n";
private final static String DOUBLE_NEW_LINE = "\n\n";


private StringBuilder sb = new StringBuilder();

// Slack으로 알림 보내기
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
@SpringBootTest
class MotivooServerApplicationTests {

@MockBean
private SlackUtil slackUtil;

@Test
void contextLoads() {
}
// @MockBean
// private SlackUtil slackUtil;
//
// @Test
// void contextLoads() {
// }

}

0 comments on commit 2bbf54e

Please sign in to comment.