Skip to content

Commit

Permalink
#36: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saneci committed Mar 12, 2024
1 parent 5c47ad5 commit d4ceaf4
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/test/java/ru/saneci/booklibrary/BaseControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ public abstract class BaseControllerTest {
getContainerInitDatabasePath("deploy-23-2.sql"))
.withCopyFileToContainer(
getDatabaseMigrationFile("r-2024-1/deploy-24-1.sql"),
getContainerInitDatabasePath("deploy-24-1.sql"));
getContainerInitDatabasePath("deploy-24-1.sql"))
.withCopyFileToContainer(
getDatabaseMigrationFile("r-2024-2/deploy-24-2.sql"),
getContainerInitDatabasePath("deploy-24-2.sql"));
}

private static MountableFile getDatabaseMigrationFile(String fileName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ void whenGetIndex_thenIndexViewShouldContainMainMenu() throws Exception {
mockMvc.perform(get("/"))
.andExpect(xpath("//*[@id='mainMenu']/nav/div[1]/h4").string("Основные разделы приложения"))
.andExpect(xpath("//*[@id='mainMenu']/nav/div[2]/a/strong").string("Книги"))
.andExpect(xpath("//*[@id='mainMenu']/nav/div[3]/a/strong").string("Новая книга"))
.andExpect(xpath("//*[@id='mainMenu']/nav/div[4]/a/strong").string("Читатели"))
.andExpect(xpath("//*[@id='mainMenu']/nav/div[3]/a/strong").string("Читатели"))
.andExpect(xpath("//*[@id='mainMenu']/nav/div[4]/a/strong").string("Новая книга"))
.andExpect(xpath("//*[@id='mainMenu']/nav/div[5]/a/strong").string("Новый читатель"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
truncate book, person;

insert into person (id, name, birthday_year) values (1, 'Test User Name', 2020);
insert into book (id, person_id, title, author, publish_year) values (1, 1, 'Test Book', 'Test Author', 1234);
insert into person (id, name, birthday_year, username, password, role)
values (1, 'Test User Name', 2020, 'username', 'password', 'ROLE_READER');

insert into book (id, person_id, title, author, publish_year)
values (1, 1, 'Test Book', 'Test Author', 1234);
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
truncate book, person;

insert into person (id, name, birthday_year) values (1, 'Test User Name', 2020);
insert into person (id, name, birthday_year, username, password, role)
values (1, 'Test User Name', 2020, 'username', 'password', 'ROLE_READER');

insert into book (id, person_id, title, author, publish_year, given_at)
values (1, 1, 'Test Book', 'Test Author', 1234, now() - interval '9 days');
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
truncate book, person;

insert into person (id, name, birthday_year) values (1, 'Test User Name', 2020);
insert into person (id, name, birthday_year, username, password, role)
values (1, 'Test User Name', 2020, 'username', 'password', 'ROLE_READER');

insert into book (id, person_id, title, author, publish_year, given_at)
values (1, 1, 'Test Book', 'Test Author', 1234, now() - interval '10 days');
3 changes: 2 additions & 1 deletion src/test/resources/sql/people_controller/create-person.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
truncate person cascade;

insert into person (id, name, birthday_year) values (1, 'Test User', 1990);
insert into person (id, name, birthday_year, username, password, role)
values (1, 'Test User', 1990, 'username', 'password', 'ROLE_READER');

0 comments on commit d4ceaf4

Please sign in to comment.