Skip to content

Commit

Permalink
#305 add test
Browse files Browse the repository at this point in the history
  • Loading branch information
yzerk committed Feb 3, 2023
1 parent 203b23f commit 8c92e92
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void populateWithDefaultValues(BaseProperties props) {
@Override
public PropertiesBuilder.Messages checkProperties(@NonNull BaseProperties props, CheckType checkType) {
PropertiesBuilder.Messages messages = new PropertiesBuilder.Messages();
if (props.getBasePath() == null) {
if (props.getApiToken() == null) {
String confFilePath = props.getConfigFilePath();
if (confFilePath == null || !(new File(confFilePath).exists())) {
throw new RuntimeException(RESOURCE_BUNDLE.getString("error.configuration_file_not_exist"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import java.io.File;

import static com.crowdin.cli.BaseCli.RESOURCE_BUNDLE;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -164,6 +165,22 @@ public void testBuildNoConfigFileTargets() {
assertThrows(NullPointerException.class, () -> propertiesBuilders.buildPropertiesWithTargets(out, null, null, okParams));
}

@Test
public void testBuildNoConfigFileAndNoToken() {
ParamsWithFiles params = new ParamsWithFiles() {{
setBasePathParam(null);
setTokenParam(null);
setSourceParam(Utils.regexPath(Utils.normalizePath("/hello/world")));
setTranslationParam("/hello/%two_letters_code%/%file_name%.%file_extension%");
}};

Exception actualException = assertThrows(RuntimeException.class, () ->
propertiesBuilders.buildPropertiesWithFiles(out, null, null, params));

assertEquals(RESOURCE_BUNDLE.getString("error.configuration_file_not_exist"), actualException.getMessage());

}

@Test
public void testPropertiesWithTarget() {
File configFile = new File("folder/crowdinTest.yml");
Expand Down

0 comments on commit 8c92e92

Please sign in to comment.