From 1cc236a683c599c7ede46a7a5c05b74ed1fcef01 Mon Sep 17 00:00:00 2001 From: geek Date: Sun, 21 Jul 2019 00:03:02 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B8=B0=EB=B3=B8=20=EA=B7=B8=EB=A3=B9=20inser?= =?UTF-8?q?t=20sql=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.yml | 4 ++-- src/main/resources/data.sql | 14 ++++++++++++++ .../server/user/repository/UserRepositoryTest.java | 11 +++++++---- 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 src/main/resources/data.sql diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index fde3cf2..0e68dda 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -12,11 +12,11 @@ spring: data-username: postgres password: qwer5795 username: postgres - # JPA properties + initialization-mode: never jpa: hibernate: - ddl-auto: create-drop + ddl-auto: update database: postgresql show-sql: true database-platform: org.hibernate.dialect.PostgreSQLDialect diff --git a/src/main/resources/data.sql b/src/main/resources/data.sql new file mode 100644 index 0000000..bb6c9bb --- /dev/null +++ b/src/main/resources/data.sql @@ -0,0 +1,14 @@ +insert into public.tbl_user_group +(id ,title, description, is_default, register_date) +values +(1, '관리자', '관리자 그룹', false, '2019-07-20 12:00:30'); + +insert into public.tbl_user_group +(id ,title, description, is_default, register_date) +values +(2, '정회원', '정회원 그룹', true, '2019-07-20 12:00:30'); + +insert into public.tbl_user_group +(id ,title, description, is_default, register_date) +values +(3, '비회원', '비회원 그룹', false, '2019-07-20 12:00:30'); diff --git a/src/test/java/com/totopia/server/user/repository/UserRepositoryTest.java b/src/test/java/com/totopia/server/user/repository/UserRepositoryTest.java index a06e71c..691b0d1 100644 --- a/src/test/java/com/totopia/server/user/repository/UserRepositoryTest.java +++ b/src/test/java/com/totopia/server/user/repository/UserRepositoryTest.java @@ -38,13 +38,16 @@ public class UserRepositoryTest { @Test public void findByUsername() throws Exception { - User tempUser = user.build(); + User admin = this.userRepository.findByUsername("admin"); + if (admin == null) { + User tempUser = user.build(); - this.userRepository.save(tempUser); + this.userRepository.save(tempUser); - User user1 = this.userRepository.findByUsername(tempUser.getUsername()); + User user1 = this.userRepository.findByUsername(tempUser.getUsername()); - assertEquals("Equlas", user.build().getUsername(), user1.getUsername()); + assertEquals("Equlas", user.build().getUsername(), user1.getUsername()); + } } @Test