Ignore empty custom configuration YAML files

We're shipping default custom configuration files that only contain a
comment, so the system should work in that case the same as if the file
didn't exist at all.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=145594737
This commit is contained in:
mcilwain 2017-01-25 14:10:24 -08:00 committed by Ben McIlwain
parent 0b1781b110
commit a8aeff96f6
2 changed files with 36 additions and 10 deletions

View file

@ -17,6 +17,7 @@ package google.registry.config;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.config.YamlUtils.mergeYaml;
import com.google.common.base.Joiner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@ -48,7 +49,14 @@ public class YamlUtilsTest {
.isEqualTo(join("non: ay", "list: [crackle, pop var]"));
}
@Test
public void testSuccess_mergeEmptyMap_isNoop() {
String defaultYaml = join("one: ay", "two: bee", "three: sea");
assertThat(mergeYaml(defaultYaml, "# Just a comment\n"))
.isEqualTo("{one: ay, two: bee, three: sea}\n");
}
private static String join(CharSequence... strings) {
return String.join("\n", strings) + "\n";
return Joiner.on('\n').join(strings) + "\n";
}
}