Skip to content

Commit

Permalink
removed todo for gradle plugin logging if error and added coverage fo…
Browse files Browse the repository at this point in the history
…r the same

Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon committed Oct 2, 2023
1 parent 834586d commit 4a51c38
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public abstract class HelmInstallChartTask extends DefaultTask {
@Input
@Optional
@Option(option = "values", description = "Specify values in a YAML file or a URL (can specify multiple)")
// TODO: enhance to support multiple values files
public abstract SetProperty<String> getValues();

@TaskAction
Expand All @@ -84,12 +83,16 @@ void installChart() {
if (getValues().isPresent()) {
optionsBuilder.values(new ArrayList<>(getValues().get()));
}
helmClient.installChart(
getRelease().getOrNull(),
new Chart(getChart().getOrNull(), getRepo().getOrNull()),
optionsBuilder.build());

getProject().getLogger().info("testing...");
// TODO log to gradle stdout if there is an error
try {
helmClient.installChart(
getRelease().getOrNull(),
new Chart(getChart().getOrNull(), getRepo().getOrNull()),
optionsBuilder.build());
} catch (Exception e) {
this.getProject()
.getLogger()
.error("HelmInstallChartTask.installChart() An ERROR occurred while installing the chart: ", e);
throw e;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import static org.junit.jupiter.api.Assertions.*;

import com.hedera.fullstack.helm.client.HelmClient;
import com.hedera.fullstack.helm.client.HelmExecutionException;
import com.hedera.fullstack.helm.client.model.Chart;
import com.hedera.fullstack.helm.client.model.Repository;
import java.io.File;
Expand Down Expand Up @@ -102,4 +103,20 @@ void testHelmInstallChartTaskSimple() {
suppressExceptions(() -> helmClient.removeRepository(REPOSITORY));
}
}

@Test
@DisplayName("test an error is thrown when the chart is not found")
void testErrorThrownWhenChartNotFound() {
assertThrows(HelmExecutionException.class, () -> {
HelmInstallChartTask helmInstallChartTask = project.getTasks()
.create("helmInstallChart", HelmInstallChartTask.class, task -> {
task.getChart().set("not-a-chart");
task.getCreateNamespace().set(true);
task.getNamespace().set("test-failure");
task.getRelease().set("not-a-release");
task.getRepo().set("not-a-repo");
});
helmInstallChartTask.installChart();
});
}
}

0 comments on commit 4a51c38

Please sign in to comment.