Skip to content

Commit

Permalink
test coverage and example
Browse files Browse the repository at this point in the history
Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon committed Oct 10, 2023
1 parent 27bdb88 commit 9e1b239
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
7 changes: 7 additions & 0 deletions fullstack-examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import com.hedera.fullstack.gradle.plugin.HelmInstallChartTask
import com.hedera.fullstack.gradle.plugin.HelmReleaseExistsTask
import com.hedera.fullstack.gradle.plugin.HelmTestChartTask
import com.hedera.fullstack.gradle.plugin.HelmUninstallChartTask

plugins {
Expand Down Expand Up @@ -59,8 +60,14 @@ tasks.register<HelmReleaseExistsTask>("helmNginxExists") {
release.set("nginx-release")
}

tasks.register<HelmTestChartTask>("helmTestNginxChart") {
namespace.set("nginx-ns")
release.set("nginx-release")
}

tasks.check {
dependsOn("helmInstallNginxChart")
dependsOn("helmNginxExists")
dependsOn("helmTestNginxChart")
dependsOn("helmUninstallNginxChart")
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ void testChart() {
try {
final String releaseName = getRelease().getOrNull();
Objects.requireNonNull(releaseName, "release name must be specified");
helmClient.testChart(
releaseName,
optionsBuilder.build());
helmClient.testChart(releaseName, optionsBuilder.build());
} catch (Exception e) {
this.getProject()
.getLogger()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ void testHelmInstallChartTaskSimple() {
task.getRelease().set(RELEASE_NAME);
});
helmReleaseExistsTask.releaseExists();
HelmTestChartTask helmTestChartTask = project.getTasks()
.create("helmTestChartTask", HelmTestChartTask.class, task -> {
task.getNamespace().set(namespace);
task.getRelease().set(RELEASE_NAME);
task.getFilter().set("test");
task.getTestTimeout().set("15m");
});
helmTestChartTask.testChart();
HelmUninstallChartTask helmUninstallChartTask = project.getTasks()
.create("helmUninstallChart", HelmUninstallChartTask.class, task -> {
task.getNamespace().set(namespace);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.hedera.fullstack.gradle.plugin;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;

import org.gradle.api.Project;
import org.gradle.testfixtures.ProjectBuilder;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

class HelmTestChartTaskTest {
private static Project project;

@BeforeAll
static void beforeAll() {
project = ProjectBuilder.builder().build();
}

@Test
@DisplayName("test an error is thrown when the release is not found")
void testErrorThrownWhenReleaseNotFound() {
NullPointerException e = assertThrows(NullPointerException.class, () -> {
HelmTestChartTask helmTestChartTask = project.getTasks()
.create("helmTestChartTaskNonExistingRelease", HelmTestChartTask.class, task -> {});
helmTestChartTask.testChart();
});
assertThat(e.getMessage()).isEqualTo("release name must be specified");
}
}

0 comments on commit 9e1b239

Please sign in to comment.