-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mongo container setup for integration tests (#1)
* change mongo container setup for integration tests * move container setup to a config class * restore TestFlashcardsApplication.java
- Loading branch information
1 parent
4da8f04
commit 0ccce37
Showing
4 changed files
with
27 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
18 changes: 4 additions & 14 deletions
18
server/src/test/java/org/hyperskill/community/flashcards/TestFlashcardsApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,13 @@ | ||
package org.hyperskill.community.flashcards; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection; | ||
import org.springframework.context.annotation.Bean; | ||
import org.testcontainers.containers.MongoDBContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
@TestConfiguration(proxyBeanMethods = false) | ||
public class TestFlashcardsApplication { | ||
|
||
@Bean | ||
@ServiceConnection | ||
MongoDBContainer mongoDbContainer() { | ||
return new MongoDBContainer(DockerImageName.parse("mongo:latest")); | ||
} | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.from(FlashcardsApplication::main).with(TestFlashcardsApplication.class).run(args); | ||
SpringApplication | ||
.from(FlashcardsApplication::main) | ||
.with(TestFlashcardsApplication.class) | ||
.run(args); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
server/src/test/java/org/hyperskill/community/flashcards/TestMongoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.hyperskill.community.flashcards; | ||
|
||
import org.springframework.boot.test.context.TestConfiguration; | ||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection; | ||
import org.springframework.context.annotation.Bean; | ||
import org.testcontainers.containers.MongoDBContainer; | ||
|
||
import java.util.List; | ||
|
||
@TestConfiguration | ||
public class TestMongoConfiguration { | ||
|
||
@Bean | ||
@ServiceConnection | ||
public MongoDBContainer mongoDBContainer() { | ||
var container = new MongoDBContainer("mongo:latest"); | ||
container.setPortBindings(List.of("27017:27017")); | ||
return container; | ||
} | ||
} |
29 changes: 2 additions & 27 deletions
29
.../src/test/java/org/hyperskill/community/flashcards/security/RegisterServerSecurityIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters