Skip to content

Commit

Permalink
refactor: remove redundant test and add relevant lines to existing test
Browse files Browse the repository at this point in the history
  • Loading branch information
at88mph committed Feb 6, 2025
1 parent 85f1ed9 commit 5dde660
Showing 1 changed file with 0 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,53 +43,10 @@ public void testParsing() throws Exception {
Assert.assertFalse("Entry not replaced.", output.contains(entry.getKey()));
Assert.assertTrue("Value not injected into file.", output.contains(entry.getValue()));
}
}

@Test
public void testWithWithoutSecret() throws Exception {
final Path testBaseValuesPath = FileUtil.getFileFromResource(
"test-base-values.yaml", SessionJobBuilderTest.class)
.toPath();
final String fileContent = Files.readString(testBaseValuesPath);

final Map<String, String> parametersToReplaceValues = new HashMap<>();
final String[] parametersToReplace = new String[] {
PostAction.SKAHA_SESSIONID,
PostAction.SKAHA_HOSTNAME,
PostAction.SKAHA_SESSIONTYPE,
PostAction.SKAHA_POSIXID
};

for (final String param : parametersToReplace) {
Assert.assertTrue("Test file is missing required field.", fileContent.contains(param));
parametersToReplaceValues.put(param, RandomStringUtils.randomAlphanumeric(12));
}

SessionJobBuilder testSubject =
SessionJobBuilder.fromPath(testBaseValuesPath).withParameters(parametersToReplaceValues);
String output = testSubject.build();

for (final Map.Entry<String, String> entry : parametersToReplaceValues.entrySet()) {
Assert.assertFalse("Entry not replaced.", output.contains(entry.getKey()));
Assert.assertTrue("Value not injected into file.", output.contains(entry.getValue()));
}

V1Job job = (V1Job) Yaml.load(output);
V1PodSpec podSpec = Objects.requireNonNull(job.getSpec()).getTemplate().getSpec();
Assert.assertNotNull("PodSpec should not be null", podSpec);
Assert.assertNull("PodSpec should not have image pull secrets", podSpec.getImagePullSecrets());

testSubject = SessionJobBuilder.fromPath(testBaseValuesPath).withParameters(parametersToReplaceValues);
output = testSubject.build();

for (final Map.Entry<String, String> entry : parametersToReplaceValues.entrySet()) {
Assert.assertFalse("Entry not replaced.", output.contains(entry.getKey()));
Assert.assertTrue("Value not injected into file.", output.contains(entry.getValue()));
}

job = (V1Job) Yaml.load(output);
podSpec = Objects.requireNonNull(job.getSpec()).getTemplate().getSpec();
Assert.assertNotNull("PodSpec should not be null", podSpec);
Assert.assertNull("PodSpec should have image pull secrets", podSpec.getImagePullSecrets());
}

Expand Down

0 comments on commit 5dde660

Please sign in to comment.