Skip to content

Commit

Permalink
Fix a case where getYamls would return an empty collection when… (#585)
Browse files Browse the repository at this point in the history
Fix a case where getYamls would return an empty collection when in fa…
  • Loading branch information
Vlatombe authored Aug 28, 2019
2 parents a847707 + 2e508f4 commit 79dd113
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public void setYaml(String yaml) {

@Nonnull
public List<String> getYamls() {
if (yamls == null) {
if (yamls == null || yamls.isEmpty()) {
if (yaml != null) {
return Collections.singletonList(yaml);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.csanchez.jenkins.plugins.kubernetes;

import org.junit.Test;

import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.empty;
import static org.junit.Assert.assertThat;

public class PodTemplateTest {
@Test
public void getYamlsExposesSingleYamlField() {
PodTemplate podTemplate = new PodTemplate();
assertThat(podTemplate.getYamls(), empty());
podTemplate.setYamls(null);
assertThat(podTemplate.getYamls(), empty());
podTemplate.setYaml("yaml");
assertThat(podTemplate.getYamls(), contains("yaml"));
podTemplate.setYaml(null);
assertThat(podTemplate.getYamls(), empty());
}
}

0 comments on commit 79dd113

Please sign in to comment.