Skip to content

Commit

Permalink
#305 fix config file checkoer
Browse files Browse the repository at this point in the history
  • Loading branch information
yzerk committed Feb 2, 2023
1 parent ad0fe68 commit 473ad2f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public class ConfigurationFilesProperties {
public File getConfigFile() {
if (configFile == null) {
configFile = this.getDefaultConfigFile();
}
else if (!configFile.exists()) {
} else if (!configFile.exists()) {
throw new RuntimeException(RESOURCE_BUNDLE.getString("error.configuration_file_not_exist"));
}
return configFile;
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/crowdin/cli/properties/BaseProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ public void populateWithDefaultValues(BaseProperties props) {
@Override
public PropertiesBuilder.Messages checkProperties(@NonNull BaseProperties props, CheckType checkType) {
PropertiesBuilder.Messages messages = new PropertiesBuilder.Messages();
String confFilePath = props.getConfigFilePath();
if (confFilePath == null || !(new File(confFilePath).exists())) {
throw new RuntimeException(RESOURCE_BUNDLE.getString("error.configuration_file_not_exist"));
if (props.getBasePath() == null) {
String confFilePath = props.getConfigFilePath();
if (confFilePath == null || !(new File(confFilePath).exists())) {
throw new RuntimeException(RESOURCE_BUNDLE.getString("error.configuration_file_not_exist"));
}
}
if (StringUtils.isEmpty(props.getApiToken())) {
messages.addError(RESOURCE_BUNDLE.getString("error.config.missed_api_token"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.crowdin.cli.utils.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import java.io.File;
Expand Down Expand Up @@ -41,6 +42,7 @@ public void testError_EverythingEmpty() {
}

@Test
@Disabled("App can not work without config file")
public void testOk_Params_WithoutConfigFile() {
ParamsWithFiles okParams = new ParamsWithFiles() {{
setIdParam("666");
Expand Down Expand Up @@ -139,6 +141,7 @@ public void testBasePropertiesWithNoValues() {
}

@Test
@Disabled("App can not work without config file")
public void testProjectProperties() {
ProjectParams params = new ProjectParams(){{
setIdParam("123");
Expand Down

0 comments on commit 473ad2f

Please sign in to comment.