Skip to content

Commit

Permalink
fix: 테스트 오류 수정
Browse files Browse the repository at this point in the history
- test의 application.properties 파일 수정
- User 엔티티 변경으로 인한 내용 반영
  • Loading branch information
wocks1123 committed May 1, 2024
1 parent e3a8fae commit 05d9b32
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void createProduct() {
images.add(mockMultipartFile1);
images.add(mockMultipartFile2);

given(userRepository.findByAccount(any())).willReturn(Optional.of(user));
given(userRepository.findByEmail(any())).willReturn(Optional.of(user));

images.forEach(image -> {
given(s3Service.uploadImage(image)).willReturn("test utl");
Expand All @@ -77,7 +77,7 @@ void createProduct() {
GuideProductDto result = guideProductService.createGuideProduct(request, images);

// then
assertThat(result.getAccount()).isEqualTo(product.getUser().getAccount());
assertThat(result.getEmail()).isEqualTo(product.getUser().getEmail());
assertThat(result.getTitle()).isEqualTo(product.getTitle());
assertThat(result.getDescription()).isEqualTo(product.getDescription());
assertThat(result.getPrice()).isEqualTo(product.getPrice());
Expand All @@ -102,7 +102,7 @@ void getProduct() {
GuideProductDto result = guideProductService.getProduct(productId);

// then
assertThat(result.getAccount()).isEqualTo(product.getUser().getAccount());
assertThat(result.getEmail()).isEqualTo(product.getUser().getEmail());
assertThat(result.getTitle()).isEqualTo(product.getTitle());
assertThat(result.getDescription()).isEqualTo(product.getDescription());
assertThat(result.getPrice()).isEqualTo(product.getPrice());
Expand Down Expand Up @@ -143,7 +143,7 @@ void modifyProduct() {
User user = product.getUser();

given(guideProductRepository.findById(any())).willReturn(Optional.of(product));
given(userRepository.findByAccount(any())).willReturn(Optional.of(user));
given(userRepository.findByEmail(any())).willReturn(Optional.of(user));

product.setGuideProduct(edit);
product.setGuideCategory(edit.getCategories());
Expand All @@ -166,10 +166,11 @@ void modifyProduct_unauthorized() {
edit.setTitle("modify title");
edit.setDescription("modify description");
GuideProduct product = GuideProductFixture.getGuideProduct();
User user = new User("wrong_account", "testemail", "testpassword");

User user = User.builder()
.email("wrong_account")
.build();
given(guideProductRepository.findById(any())).willReturn(Optional.of(product));
given(userRepository.findByAccount(any())).willReturn(Optional.of(user));
given(userRepository.findByEmail(any())).willReturn(Optional.of(user));

// when
Throwable throwable = catchThrowable(() -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static GuideProduct getGuideProduct() {
images.add(new GuideImage("test url2"));

GuideProduct product = new GuideProduct(
new User("account1", "testemail", "testpassword"),
User.builder().email("wrong_account").build(),
"test title",
"test description",
20000L,
Expand Down
25 changes: 14 additions & 11 deletions src/test/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
spring.application.name=backend
version=${version}
version=test
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=${DATASOURCE_URL}
spring.datasource.username=${DATASOURCE_USERNAME}
spring.datasource.password=${DATASOURCE_PASSWORD}
jwt.secret.key=${JWT_SECRET_KEY}
google.client.secret=${GOOGLE_AUTH_SECRET}
google.client.id=${GOOGLE_CLIENT_ID}
spring.datasource.url=\${DATASOURCE_URL}
spring.datasource.username=\${DATASOURCE_USERNAME}
spring.datasource.password=\${DATASOURCE_PASSWORD}
jwt.secret.key=\${JWT_SECRET_KEY}
google.client.secret=\${GOOGLE_AUTH_SECRET}
google.client.id=\${GOOGLE_CLIENT_ID}
google.client.redirect=\${GOOGLE_REDIRECT_URI}
spring.security.oauth2.client.registration.google.scope=profile,email,openid
cloud.aws.credentials.access-key=${AWS_CREDENTIAL_ACCESS_KEY}
cloud.aws.credentials.secret-key=${AWS_CREDENTIAL_SECRET_KEY}
cloud.aws.s3.bucket=${AWS_S3_BUCEKT_NAME}
cloud.aws.region.static=${AWS_REGION_STATIC}
cloud.aws.credentials.access-key=\${AWS_CREDENTIAL_ACCESS_KEY}
cloud.aws.credentials.secret-key=\${AWS_CREDENTIAL_SECRET_KEY}
cloud.aws.s3.bucket=\${AWS_S3_BUCEKT_NAME}
cloud.aws.region.static=\${AWS_REGION_STATIC}
imp.v1.api.key=\${IMP_API_KEY}
imp.v1.api.secret=\${IMP_API_SECRET}

0 comments on commit 05d9b32

Please sign in to comment.