Skip to content

Commit

Permalink
test: Test code for ProfileController
Browse files Browse the repository at this point in the history
Issue #35
  • Loading branch information
suhyunsim committed Dec 29, 2020
1 parent 754c347 commit ce85ba5
Showing 1 changed file with 59 additions and 0 deletions.
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);
}
}

0 comments on commit ce85ba5

Please sign in to comment.