use of com.thoughtworks.go.server.domain.support.toggle.FeatureToggles in project gocd by gocd.
the class FeatureToggleRepositoryTest method shouldNotFailWhenSpecifiedUserTogglesFileIsNotFound.
@Test
public void shouldNotFailWhenSpecifiedUserTogglesFileIsNotFound() throws Exception {
setupUserToggleFileAs(new File("a-non-existent-file"));
FeatureToggleRepository repository = new FeatureToggleRepository(environment);
assertThat(repository.userToggles(), is(new FeatureToggles()));
}
use of com.thoughtworks.go.server.domain.support.toggle.FeatureToggles in project gocd by gocd.
the class FeatureToggleServiceTest method shouldOverrideAvailableToggleValuesWithValuesFromUsersToggles.
@Test
public void shouldOverrideAvailableToggleValuesWithValuesFromUsersToggles() throws Exception {
FeatureToggle availableToggle1 = new FeatureToggle("key1", "desc1", true);
FeatureToggle availableToggle2 = new FeatureToggle("key2", "desc2", true);
FeatureToggle availableToggle3 = new FeatureToggle("key3", "desc3", true);
when(repository.availableToggles()).thenReturn(new FeatureToggles(availableToggle1, availableToggle2, availableToggle3));
FeatureToggle userToggle1 = new FeatureToggle("key1", "NEW_desc1_WITH_NO_change_to_value", true);
FeatureToggle userToggle2 = new FeatureToggle("key2", "NEW_desc2_WITH_CHANGE_TO_VALUE", false);
when(repository.userToggles()).thenReturn(new FeatureToggles(userToggle1, userToggle2));
FeatureToggleService service = new FeatureToggleService(repository, goCache);
FeatureToggles toggles = service.allToggles();
assertThat(toggles.all().size(), is(3));
assertThat(toggles.all().get(0), is(new FeatureToggle("key1", "NEW_desc1_WITH_NO_change_to_value", true).withValueHasBeenChangedFlag(false)));
assertThat(toggles.all().get(1), is(new FeatureToggle("key2", "NEW_desc2_WITH_CHANGE_TO_VALUE", false).withValueHasBeenChangedFlag(true)));
assertThat(toggles.all().get(2), is(new FeatureToggle("key3", "desc3", true).withValueHasBeenChangedFlag(false)));
}
use of com.thoughtworks.go.server.domain.support.toggle.FeatureToggles in project gocd by gocd.
the class FeatureToggleServiceTest method shouldNotAllowChangingValueOfAnInvalidFeatureToggle.
@Test
public void shouldNotAllowChangingValueOfAnInvalidFeatureToggle() throws Exception {
FeatureToggle availableToggle1 = new FeatureToggle("key1", "desc1", true);
when(repository.availableToggles()).thenReturn(new FeatureToggles(availableToggle1));
when(repository.userToggles()).thenReturn(new FeatureToggles());
FeatureToggleService service = new FeatureToggleService(repository, goCache);
try {
service.changeValueOfToggle("keyNOTVALID", true);
fail("This should have failed with an exception, since the feature toggle is invalid.");
} catch (RuntimeException e) {
assertThat(e.getMessage(), is("Feature toggle: 'keyNOTVALID' is not valid."));
}
}
use of com.thoughtworks.go.server.domain.support.toggle.FeatureToggles in project gocd by gocd.
the class FeatureToggleServiceTest method shouldSayThatNonExistentTogglesAreOff.
@Test
public void shouldSayThatNonExistentTogglesAreOff() throws Exception {
FeatureToggles existingToggles = new FeatureToggles(new FeatureToggle("key1", "description1", true), new FeatureToggle("key2", "description2", false));
when(repository.availableToggles()).thenReturn(existingToggles);
when(repository.userToggles()).thenReturn(new FeatureToggles());
FeatureToggleService service = new FeatureToggleService(repository, goCache);
assertThat(service.isToggleOn("NON_EXISTENT_KEY"), is(false));
}
Aggregations