Skip to content

Commit

Permalink
test: 발송 옵션 조회 기능 테스트 #3
Browse files Browse the repository at this point in the history
  • Loading branch information
623nana committed Jul 27, 2021
1 parent 9be6a20 commit 19bc364
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.nexters.covid.letter.domain;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;

@DataJpaTest
public class SendOptionRepositoryTest {

@Autowired
SendOptionRepository sendOptionRepository;

@Test
void fetchJoinTest() {
List<SendOption> options = sendOptionRepository.findAllJoinFetch();

assertThat(options.size()).isEqualTo(5);
}
}
11 changes: 11 additions & 0 deletions src/test/java/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:testdb
data: classpath:data-h2.sql
h2:
console:
enabled: true
jpa:
defer-datasource-initialization: true
show-sql: true
16 changes: 16 additions & 0 deletions src/test/java/resources/data-h2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
insert into user (email, identifier, name) values ('email', 'identifier', 'name');

insert into letter (answer, contents, encrypted_id, letter_to, email, sticker, question_id, state, title, user_id)
values ('ANSWER', 'CONTENTS', 'ENCRYPTED', 'LETTER_TO', 'email', 'A', 'HAPPY', 'PENDING', 'TITLE', 1);
insert into letter (answer, contents, encrypted_id, letter_to, email, sticker, question_id, state, title, user_id)
values ('ANSWER1', 'CONTENTS1', 'ENCRYPTED1', 'LETTER_TO1', 'email', 'A', 'BLUE', 'PENDING', 'TITLE1', 1);

insert into send_option (text, covid_stat) values ('테스트', 1000);
insert into send_option (text, covid_stat) values ('테스트2', 2000);

insert into question (text, send_option_id) values ('테스트1에 1', 1);
insert into question (text, send_option_id) values ('테스트1에 2', 1);
insert into question (text, send_option_id) values ('테스트1에 3', 1);

insert into question (text, send_option_id) values ('테스트2에 1', 2);
insert into question (text, send_option_id) values ('테스트2에 2', 2);

0 comments on commit 19bc364

Please sign in to comment.