Skip to content

Commit

Permalink
Update AppTest
Browse files Browse the repository at this point in the history
  • Loading branch information
zHd4 committed Feb 18, 2024
1 parent 43ce8bc commit 27c6cd6
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions app/src/test/java/hexlet/code/AppTest.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package hexlet.code;

import hexlet.code.model.Url;
import hexlet.code.repository.BaseRepository;
import hexlet.code.repository.UrlsRepository;
import io.javalin.Javalin;
import kong.unirest.HttpResponse;
Expand All @@ -18,6 +17,8 @@

import static org.assertj.core.api.Assertions.assertThat;
import static hexlet.code.util.FormatUtils.formatTimestamp;
import static hexlet.code.util.Resources.readResourceFile;
import static hexlet.code.repository.BaseRepository.runScript;

public final class AppTest {
private static final int PORT = 0;
Expand All @@ -38,20 +39,9 @@ public static void afterAll() {
}

@AfterEach
void afterEach() throws SQLException {
BaseRepository.runScript("DELETE FROM urls;");
BaseRepository.runScript("ALTER TABLE urls ALTER COLUMN id RESTART WITH 4;");

BaseRepository.runScript("""
INSERT INTO urls (id, name, created_at)
VALUES (1, 'https://github.com', '2024-02-17 00:40:12.491151');
INSERT INTO urls (id, name, created_at)
VALUES (2, 'https://google.com', '2024-02-17 00:41:06.273015');
INSERT INTO urls (id, name, created_at)
VALUES (3, 'https://microsoft.com', '2024-02-17 00:41:51.817112');""");

void afterEach() throws SQLException, IOException {
runScript(readResourceFile("truncate.sql"));
runScript(readResourceFile("seed.sql"));
}

@Test
Expand Down

0 comments on commit 27c6cd6

Please sign in to comment.