|
9 | 9 |
|
10 | 10 | import static io.harness.annotations.dev.HarnessTeam.PIPELINE; |
11 | 11 | import static io.harness.pms.merger.helpers.MergeHelper.mergeRuntimeInputValuesIntoOriginalYaml; |
| 12 | +import static io.harness.rule.OwnerRule.DEV_MITTAL; |
12 | 13 | import static io.harness.rule.OwnerRule.NAMAN; |
13 | 14 |
|
14 | 15 | import static org.assertj.core.api.Assertions.assertThat; |
@@ -120,6 +121,53 @@ public void testMergeYamlUpdates() throws IOException { |
120 | 121 | assertThat(noUpdatesOnYaml).isEqualTo(readFile("opa-pipeline.json")); |
121 | 122 | } |
122 | 123 |
|
| 124 | + @Test |
| 125 | + @Owner(developers = DEV_MITTAL) |
| 126 | + @Category(UnitTests.class) |
| 127 | + public void testMergeYamlUpdatesEmojis() throws IOException { |
| 128 | + String filename = "opa-pipeline.yaml"; |
| 129 | + String pipeline = readFile(filename); |
| 130 | + |
| 131 | + String fqn1 = "pipeline/stages/[0]/stage/spec/execution/steps/[0]/step/spec/connector"; |
| 132 | + String exp1 = readFile("emojiExp1.txt"); |
| 133 | + |
| 134 | + String fqn2 = "pipeline/stages/[1]/stage/spec/infrastructure/environment"; |
| 135 | + String exp2 = readFile("emojiExp2.txt"); |
| 136 | + |
| 137 | + Map<String, String> fqnToJsonMap = new HashMap<>(); |
| 138 | + fqnToJsonMap.put(fqn1, exp1); |
| 139 | + fqnToJsonMap.put(fqn2, exp2); |
| 140 | + String expandedPipeline = MergeHelper.mergeUpdatesIntoJson(pipeline, fqnToJsonMap); |
| 141 | + assertThat(expandedPipeline).isNotNull(); |
| 142 | + String expandedPipelineExpected = readFile("opa-pipeline-with-expansions-no-removals.json"); |
| 143 | + assertThat(expandedPipeline).isEqualTo(expandedPipelineExpected); |
| 144 | + YamlField yamlField = YamlUtils.readTree(expandedPipeline); |
| 145 | + YamlNode firstExp = |
| 146 | + yamlField.getNode().gotoPath("pipeline/stages/[0]/stage/spec/execution/steps/[0]/step/spec/connector"); |
| 147 | + YamlNode secondExp = yamlField.getNode().gotoPath("pipeline/stages/[1]/stage/spec/infrastructure/environment"); |
| 148 | + assertThat(firstExp).isNotNull(); |
| 149 | + assertThat(secondExp).isNotNull(); |
| 150 | + |
| 151 | + String noUpdates = MergeHelper.mergeUpdatesIntoJson(expandedPipeline, null); |
| 152 | + assertThat(noUpdates).isEqualTo(expandedPipeline); |
| 153 | + |
| 154 | + String noUpdatesOnYaml = MergeHelper.mergeUpdatesIntoJson(pipeline, null); |
| 155 | + assertThat(noUpdatesOnYaml).isEqualTo(readFile("opa-pipeline.json")); |
| 156 | + } |
| 157 | + |
| 158 | + @Test |
| 159 | + @Owner(developers = DEV_MITTAL) |
| 160 | + @Category(UnitTests.class) |
| 161 | + public void testRemoveNonASCII() { |
| 162 | + String asciiString = ""; |
| 163 | + for (int i = 0; i < 128; i++) { |
| 164 | + asciiString += (char) i; |
| 165 | + } |
| 166 | + assertThat(MergeHelper.removeNonASCII(asciiString)).isEqualTo(asciiString); |
| 167 | + assertThat(MergeHelper.removeNonASCII(asciiString + "\ud330\ud803\ud823")).isEqualTo(asciiString); |
| 168 | + assertThat(MergeHelper.removeNonASCII("\ud230\ud803\ud123" + asciiString)).isEqualTo(asciiString); |
| 169 | + } |
| 170 | + |
123 | 171 | @Test |
124 | 172 | @Owner(developers = NAMAN) |
125 | 173 | @Category(UnitTests.class) |
|
0 commit comments