-
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.
test: Test code for ProfileController
Issue #35
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
src/test/java/com/poogle/phog/web/profile/controller/ProfileControllerUnitTest.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,59 @@ | ||
package com.poogle.phog.web.profile.controller; | ||
|
||
import org.junit.Test; | ||
import org.springframework.mock.env.MockEnvironment; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ProfileControllerUnitTest { | ||
|
||
@Test | ||
public void deploy_profile이_조회된다() { | ||
//given | ||
String expectedProfile = "deploy"; | ||
MockEnvironment env = new MockEnvironment(); | ||
env.addActiveProfile(expectedProfile); | ||
env.addActiveProfile("oauth"); | ||
env.addActiveProfile("real-db"); | ||
|
||
ProfileController controller = new ProfileController(env); | ||
|
||
//when | ||
String profile = controller.profile(); | ||
|
||
//then | ||
assertThat(profile).isEqualTo(expectedProfile); | ||
} | ||
|
||
@Test | ||
public void deploy_profile이_없으면_첫_번째가_조회된다() { | ||
//given | ||
String expactedProfile = "oauth"; | ||
MockEnvironment env = new MockEnvironment(); | ||
|
||
env.addActiveProfile(expactedProfile); | ||
env.addActiveProfile("real"); | ||
|
||
ProfileController controller = new ProfileController(env); | ||
|
||
//when | ||
String profile = controller.profile(); | ||
|
||
//then | ||
assertThat(profile).isEqualTo(expactedProfile); | ||
} | ||
|
||
@Test | ||
public void active_profile이_없으면_default가_조회된다() { | ||
//given | ||
String expectedProfile = "default"; | ||
MockEnvironment env = new MockEnvironment(); | ||
ProfileController controller = new ProfileController(env); | ||
|
||
//when | ||
String profile = controller.profile(); | ||
|
||
//then | ||
assertThat(profile).isEqualTo(expectedProfile); | ||
} | ||
} |