diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1d2522d..d0166dc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,9 @@ jobs: echo "encoder_memory=65536" >> $GITHUB_ENV echo "encoder_iterations=3" >> $GITHUB_ENV + - name: Run unit tests + run: mvn clean test + - name: Build & run containers run: docker compose up --build -d diff --git a/pom.xml b/pom.xml index 8bdf632..e165590 100644 --- a/pom.xml +++ b/pom.xml @@ -18,7 +18,6 @@ org.springframework.boot spring-boot-starter-web - 3.5.5 org.springdoc @@ -28,7 +27,6 @@ org.springframework.boot spring-boot-starter-data-jpa - 3.5.0 com.mysql @@ -38,7 +36,6 @@ org.springframework.boot spring-boot-starter-security - 3.5.0 org.bouncycastle @@ -60,6 +57,11 @@ jjwt-jackson 0.11.5 + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 66d5ad0..8d06483 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -16,7 +16,6 @@ spring.jpa.show-sql=true spring.jpa.properties.hibernate.format_sql=true logging.level.com.zaxxer.hikari=DEBUG - # =============================== # = JWT # =============================== @@ -32,7 +31,6 @@ spring.datasource.hikari.connectionTimeout=30000 spring.datasource.hikari.maxLifetime=600000 spring.datasource.hikari.initialization-fail-timeout=-1 - # =============================== # = ADMIN # =============================== diff --git a/src/test/java/com/application/socials/SocialMediaServiceTest.java b/src/test/java/com/application/socials/SocialMediaServiceTest.java new file mode 100644 index 0000000..488a533 --- /dev/null +++ b/src/test/java/com/application/socials/SocialMediaServiceTest.java @@ -0,0 +1,20 @@ +package com.application.socials; + +import com.domain.models.Socials; +import org.junit.jupiter.api.Test; +import static org.mockito.Mockito.*; +import static org.junit.jupiter.api.Assertions.*; + +class SocialMediaServiceTest { + + @Test + void testCreateSocials() { + + SocialMediaRepository repoMock = mock(SocialMediaRepository.class); + when(repoMock.createSocials(any(Socials.class), eq(1L))).thenReturn(42L); + SocialMediaService service = new SocialMediaService(repoMock); + Long result = service.createSocials("githubUser", "linkedinUser", 1L); + assertEquals(42L, result); + verify(repoMock, times(1)).createSocials(any(Socials.class), eq(1L)); + } +}