Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 5eb36bf
Author: Jeromy Cannon <[email protected]>
Date:   Mon Oct 2 21:30:37 2023 +0100

    remove public modifier

    Signed-off-by: Jeromy Cannon <[email protected]>

commit a18cfa8
Author: Jeromy Cannon <[email protected]>
Date:   Mon Oct 2 20:45:40 2023 +0100

    more test coverage

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 05592cb
Author: Jeromy Cannon <[email protected]>
Date:   Mon Oct 2 20:38:43 2023 +0100

    removed system out println

    Signed-off-by: Jeromy Cannon <[email protected]>

commit e1cac52
Author: Jeromy Cannon <[email protected]>
Date:   Mon Oct 2 20:37:02 2023 +0100

    increase test coverage

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 57770ee
Author: Jeromy Cannon <[email protected]>
Date:   Mon Oct 2 20:36:51 2023 +0100

    added workingDirectory override abilities into helm client for using within test cases

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 7fe0aae
Author: Jeromy Cannon <[email protected]>
Date:   Mon Oct 2 19:02:55 2023 +0100

    added helm client dependency update

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 5f4d57c
Author: Jeromy Cannon <[email protected]>
Date:   Mon Oct 2 19:05:28 2023 +0100

    fix failing test case

    Signed-off-by: Jeromy Cannon <[email protected]>

commit d61a652
Author: Jeromy Cannon <[email protected]>
Date:   Mon Oct 2 16:53:14 2023 +0100

    test coverage

    Signed-off-by: Jeromy Cannon <[email protected]>

commit d813231
Author: Jeromy Cannon <[email protected]>
Date:   Fri Sep 29 16:58:16 2023 +0100

    testChart(String releaseName, TestChartOptions options)

    Signed-off-by: Jeromy Cannon <[email protected]>

commit c7aaf6c
Author: Jeromy Cannon <[email protected]>
Date:   Thu Sep 28 19:54:15 2023 +0100

    HelmUninstallChartTask code/examples/test coverage

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 6240d28
Author: Jeromy Cannon <[email protected]>
Date:   Wed Sep 27 17:18:35 2023 +0100

    fix test case failure

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 4a51c38
Author: Jeromy Cannon <[email protected]>
Date:   Wed Sep 27 14:47:16 2023 +0100

    removed todo for gradle plugin logging if error and added coverage for the same

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 834586d
Author: Jeromy Cannon <[email protected]>
Date:   Tue Sep 26 21:15:39 2023 +0100

    gradle-executable path provided

    Signed-off-by: Jeromy Cannon <[email protected]>

commit c2cbdbf
Author: Jeromy Cannon <[email protected]>
Date:   Tue Sep 26 20:52:32 2023 +0100

    gradle-executable path provided

    Signed-off-by: Jeromy Cannon <[email protected]>

commit a7540dc
Author: Jeromy Cannon <[email protected]>
Date:   Tue Sep 26 18:35:14 2023 +0100

    gradle-executable shouldn't be needed...

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 480c288
Author: Jeromy Cannon <[email protected]>
Date:   Tue Sep 26 18:12:35 2023 +0100

    supply gradle executable directory for new jobs

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 719b24b
Author: Jeromy Cannon <[email protected]>
Date:   Tue Sep 26 18:03:21 2023 +0100

    supply gradle executable directory for new jobs

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 67e9c1c
Author: Jeromy Cannon <[email protected]>
Date:   Tue Sep 26 17:39:47 2023 +0100

    Examples Spotless Check

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 9c40db5
Author: Jeromy Cannon <[email protected]>
Date:   Tue Sep 26 17:35:06 2023 +0100

    update job ids for new jobs

    Signed-off-by: Jeromy Cannon <[email protected]>

commit c80aa8b
Author: Jeromy Cannon <[email protected]>
Date:   Tue Sep 26 17:31:18 2023 +0100

    add compile and unit test jobs for examples project since they are now separate

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 4475c6a
Author: Jeromy Cannon <[email protected]>
Date:   Tue Sep 26 17:21:14 2023 +0100

    updates based on feedback from Jendrick on hedera-services changes.

    Signed-off-by: Jeromy Cannon <[email protected]>

commit dd90490
Author: Jeromy Cannon <[email protected]>
Date:   Tue Sep 26 09:41:51 2023 +0100

    updates based on changes in helm install subcommand

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 6f436e6
Author: Jeromy Cannon <[email protected]>
Date:   Mon Sep 25 14:42:22 2023 +0100

    temporarily disable fullstack-examples until we can resolve intellij and sonar issues

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 962080e
Author: Jeromy Cannon <[email protected]>
Date:   Fri Sep 22 20:12:30 2023 +0100

    Squashed commit of the following:

    commit d177c82
    Author: Jeromy Cannon <[email protected]>
    Date:   Thu Sep 21 19:02:43 2023 +0100

        updated HelmExecutionBuilder workingDirectory to use PWD instead of new File('.') from FileUtils

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 7ef57c1
    Author: Jeromy Cannon <[email protected]>
    Date:   Thu Sep 21 14:09:23 2023 +0100

        removed commented out code that was previously used for shadowjars

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 4891dd5
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 20:02:40 2023 +0100

        remove shadowjars

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 9d67a54
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 19:48:24 2023 +0100

        remove shadowjars

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 3dc75a0
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 19:43:55 2023 +0100

        todo

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 7660afb
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 19:42:46 2023 +0100

        more todo's

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 51df393
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 18:04:31 2023 +0100

        switch to a different repo to avoid test collisions

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 44754c1
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 17:35:19 2023 +0100

        remove code smells

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit d068f26
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 16:25:05 2023 +0100

        updated HelmInstallChartTaskTest to different chart/repo to avoid collisions with other tests

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 7821d6f
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 13:10:07 2023 +0100

        add licenses at top of kotlin files

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit ae3d3c7
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 13:02:06 2023 +0100

        added TODO

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 4a82261
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 12:53:04 2023 +0100

        Revert "removed unneeded test implementation reference"

        This reverts commit 8eedff9.

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 674c155
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 12:49:28 2023 +0100

        removed unneeded test implementation reference

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 23c3104
    Author: Jeromy Cannon <[email protected]>
    Date:   Wed Sep 20 12:45:25 2023 +0100

        upcoming todo for next PR

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 72bf7b3
    Author: Jeromy Cannon <[email protected]>
    Date:   Tue Sep 19 22:26:19 2023 +0100

        removed commented out code

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit aec75d3
    Author: Jeromy Cannon <[email protected]>
    Date:   Tue Sep 19 22:24:54 2023 +0100

        FileUtils.getWorkingPath()

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 50e2a0e
    Author: Jeromy Cannon <[email protected]>
    Date:   Tue Sep 19 22:21:05 2023 +0100

        remove commented out code

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 659283b
    Author: Jeromy Cannon <[email protected]>
    Date:   Tue Sep 19 22:20:56 2023 +0100

        remove commented out code

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 5fb6e86
    Author: Jeromy Cannon <[email protected]>
    Date:   Tue Sep 19 22:20:30 2023 +0100

        added namespace and create namespace and example chart for installing during build check

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 6102441
    Author: Jeromy Cannon <[email protected]>
    Date:   Mon Sep 18 19:44:36 2023 +0100

        working version

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 7e06feb
    Author: Jeromy Cannon <[email protected]>
    Date:   Mon Sep 18 19:29:05 2023 +0100

        task working

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 19c176b
    Author: Jeromy Cannon <[email protected]>
    Date:   Mon Sep 18 19:06:37 2023 +0100

        non-working version

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 9e2e66f
    Author: Jeromy Cannon <[email protected]>
    Date:   Mon Sep 18 17:01:59 2023 +0100

        compiling version although not executing of moving integration tests into examples

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit c5a9b8a
    Author: Jeromy Cannon <[email protected]>
    Date:   Fri Sep 15 18:30:00 2023 +0100

        added logic to set the namespace in the helm install task

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit dc85197
    Author: Jeromy Cannon <[email protected]>
    Date:   Fri Sep 15 17:47:30 2023 +0100

        removed duplicate export

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 6710059
    Author: Jeromy Cannon <[email protected]>
    Date:   Fri Sep 15 17:28:10 2023 +0100

        added support for set and values parameters of install subcommand to handle sets

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 0d49686
    Author: Jeromy Cannon <[email protected]>
    Date:   Fri Sep 15 17:27:21 2023 +0100

        enhanced helm client to handle sets of strings for values and set parameters for the install subcommand

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 3f634e0
    Author: Jeromy Cannon <[email protected]>
    Date:   Thu Sep 14 19:39:03 2023 +0100

        test nmt install

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit a760d52
    Author: Jeromy Cannon <[email protected]>
    Date:   Thu Sep 14 19:06:12 2023 +0100

        update version from 0.7.0 to 0.8.0

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 3c2a99b
    Author: Jeromy Cannon <[email protected]>
    Date:   Thu Sep 14 19:04:34 2023 +0100

        todo

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 77c59ef
    Author: Jeromy Cannon <[email protected]>
    Date:   Thu Sep 14 18:57:51 2023 +0100

        removed comment from FullstackPlugin.java

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 840f64b
    Author: Jeromy Cannon <[email protected]>
    Date:   Thu Sep 14 18:56:19 2023 +0100

        reordered alphabetically

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 28005ad
    Author: Jeromy Cannon <[email protected]>
    Date:   Thu Sep 14 18:53:54 2023 +0100

        added set parameter

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit 1d03540
    Author: Jeromy Cannon <[email protected]>
    Date:   Thu Sep 14 18:32:07 2023 +0100

        update after merge from main made a mess (part2)

        Signed-off-by: Jeromy Cannon <[email protected]>

    commit bb254c6
    Author: Jeromy Cannon <[email protected]>
    Date:   Thu Sep 14 18:26:36 2023 +0100

        update after merge from main made a mess

        Signed-off-by: Jeromy Cannon <[email protected]>

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 7c5b663
Author: Jeromy Cannon <[email protected]>
Date:   Mon Oct 2 17:07:26 2023 +0100

    better rename for options with multiple values

    Signed-off-by: Jeromy Cannon <[email protected]>

commit db5283d
Author: Jeromy Cannon <[email protected]>
Date:   Mon Sep 25 21:45:18 2023 +0100

    updates based on code review

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 72757ac
Author: Jeromy Cannon <[email protected]>
Date:   Mon Sep 25 13:40:35 2023 +0100

    sonar changes

    Signed-off-by: Jeromy Cannon <[email protected]>

commit d1b70f8
Author: Jeromy Cannon <[email protected]>
Date:   Fri Sep 22 19:55:41 2023 +0100

    coverage for ChartInstallRequest.apply()

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 622fd31
Author: Jeromy Cannon <[email protected]>
Date:   Fri Sep 22 19:55:13 2023 +0100

    spotlessApply

    Signed-off-by: Jeromy Cannon <[email protected]>

commit 25ca488
Author: Jeromy Cannon <[email protected]>
Date:   Fri Sep 22 18:55:38 2023 +0100

    only %n for string.format

    Signed-off-by: Jeromy Cannon <[email protected]>

commit c9c45f9
Author: Jeromy Cannon <[email protected]>
Date:   Thu Sep 21 20:26:55 2023 +0100

    GMD: Enhance Helm Install to support multiple set and values parameters #366

    Signed-off-by: Jeromy Cannon <[email protected]>

Signed-off-by: Jeromy Cannon <[email protected]>
  • Loading branch information
jeromy-cannon committed Oct 5, 2023
1 parent 572e900 commit 61f48a9
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ default Release installChart(String releaseName, Chart chart) {
*/
void testChart(String releaseName, TestChartOptions options);

/**
* Executes the Helm CLI {@code dependency update} sub-command and updates the dependencies of the specified Helm
* chart.
*
* @param chartName the name of the chart to update.
*/
void dependencyUpdate(String chartName);

/**
* Creates a new {@link HelmClientBuilder} instance with the default configuration.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ public interface HelmClientBuilder {
*/
HelmClientBuilder defaultNamespace(String namespace);

/**
* Sets the working directory for the {@link HelmClient} instance.
* @param workingDirectory the working directory.
* @return the {@link HelmClientBuilder} instance.
* @implNote The working directory is set to the pwd if not explicitly provided, if that fails it will use the
* parent folder of the helm executable.
*/
HelmClientBuilder workingDirectory(Path workingDirectory);

/**
* Sets the Kubernetes API server address and port number for the {@link HelmClient} instance.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.hedera.fullstack.helm.client.model.test.TestChartOptions;
import com.hedera.fullstack.helm.client.proxy.request.HelmRequest;
import com.hedera.fullstack.helm.client.proxy.request.authentication.KubeAuthentication;
import com.hedera.fullstack.helm.client.proxy.request.chart.ChartDependencyUpdateRequest;
import com.hedera.fullstack.helm.client.proxy.request.chart.ChartInstallRequest;
import com.hedera.fullstack.helm.client.proxy.request.chart.ChartTestRequest;
import com.hedera.fullstack.helm.client.proxy.request.chart.ChartUninstallRequest;
Expand Down Expand Up @@ -69,6 +70,11 @@ public final class DefaultHelmClient implements HelmClient {
*/
private final String defaultNamespace;

/**
* The working directory to use when executing Helm commands.
*/
private final Path workingDirectory;

/**
* Creates a new instance of the {@link DefaultHelmClient} class.
*
Expand All @@ -78,9 +84,26 @@ public final class DefaultHelmClient implements HelmClient {
*/
public DefaultHelmClient(
final Path helmExecutable, final KubeAuthentication authentication, final String defaultNamespace) {
this(helmExecutable, authentication, defaultNamespace, null);
}

/**
* Creates a new instance of the {@link DefaultHelmClient} class.
*
* @param helmExecutable the path to the Helm executable.
* @param authentication the authentication configuration to use when executing Helm commands.
* @param defaultNamespace the default namespace to use when executing Helm commands.
* @param workingDirectory the working directory to use when executing Helm commands.
*/
public DefaultHelmClient(
final Path helmExecutable,
final KubeAuthentication authentication,
final String defaultNamespace,
final Path workingDirectory) {
this.helmExecutable = Objects.requireNonNull(helmExecutable, "helmExecutable must not be null");
this.authentication = Objects.requireNonNull(authentication, "authentication must not be null");
this.defaultNamespace = defaultNamespace;
this.workingDirectory = workingDirectory;
}

@Override
Expand Down Expand Up @@ -130,6 +153,14 @@ public void testChart(final String releaseName, final TestChartOptions options)
});
}

@Override
public void dependencyUpdate(final String chartName) {
executeInternal(new ChartDependencyUpdateRequest(chartName), Void.class, (b, c) -> {
b.call();
return null;
});
}

/**
* Applies the default namespace and authentication configuration to the given builder.
*
Expand All @@ -140,11 +171,16 @@ private void applyBuilderDefaults(final HelmExecutionBuilder builder) {
builder.argument(NAMESPACE_ARG_NAME, defaultNamespace);
}

if (workingDirectory != null) {
builder.workingDirectory(workingDirectory);
}

authentication.apply(builder);
}

/**
* Executes the given request and returns the response as the given class. The request is executed using the default namespace.
* Executes the given request and returns the response as the given class. The request is executed using the default
* namespace.
*
* @param request the request to execute.
* @param responseClass the class of the response.
Expand Down Expand Up @@ -172,7 +208,8 @@ private <T extends HelmRequest, R> R execute(
}

/**
* Executes the given request and returns the response as a list of the given class. The request is executed using the default namespace.
* Executes the given request and returns the response as a list of the given class. The request is executed using
* the default namespace.
*
* @param request the request to execute.
* @param responseClass the class of the response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public final class DefaultHelmClientBuilder implements HelmClientBuilder {
*/
private String defaultNamespace;

/**
* The working directory to be used by the {@link HelmClient}.
*/
private Path workingDirectory;

/**
* The kubernetes API server address and port number to which the client should connect. Defaults to a {@code null}
* value which indicates that the Helm {@code --kube-apiserver <address_and_port>} argument should not be specified.
Expand Down Expand Up @@ -86,6 +91,12 @@ public HelmClientBuilder defaultNamespace(final String namespace) {
return this;
}

@Override
public HelmClientBuilder workingDirectory(final Path workingDirectory) {
this.workingDirectory = workingDirectory;
return this;
}

@Override
public HelmClientBuilder kubeApiServer(String kubeApiServer) {
this.kubeApiServer = kubeApiServer;
Expand Down Expand Up @@ -139,6 +150,6 @@ public HelmClient build() {
kubeTlsServerName,
kubeToken,
kubeConfig);
return new DefaultHelmClient(helmExecutable, kubeAuthentication, defaultNamespace);
return new DefaultHelmClient(helmExecutable, kubeAuthentication, defaultNamespace, workingDirectory);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.helm.client.proxy.request.chart;

import com.hedera.fullstack.helm.client.execution.HelmExecutionBuilder;
import com.hedera.fullstack.helm.client.proxy.request.HelmRequest;
import java.util.Objects;

/**
* A request to do a dependency update on a chart.
*
* @param chartName the name of the chart to update.
*/
public record ChartDependencyUpdateRequest(String chartName) implements HelmRequest {
public ChartDependencyUpdateRequest {
Objects.requireNonNull(chartName, "chartName must not be null");
if (chartName.isBlank()) {
throw new IllegalArgumentException("chartName must not be blank");
}
}

@Override
public void apply(HelmExecutionBuilder builder) {
builder.subcommands("dependency", "update");
builder.positional(chartName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

import static com.hedera.fullstack.base.api.util.ExceptionUtils.suppressExceptions;
import static org.assertj.core.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Named.named;

import com.hedera.fullstack.base.api.version.SemanticVersion;
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 com.hedera.fullstack.helm.client.model.chart.Release;
Expand All @@ -32,6 +34,7 @@
import com.jcovalent.junit.logging.LogEntryBuilder;
import com.jcovalent.junit.logging.LoggingOutput;
import com.jcovalent.junit.logging.assertj.LoggingOutputAssert;
import java.io.File;
import java.util.List;
import java.util.stream.Stream;
import org.junit.jupiter.api.*;
Expand Down Expand Up @@ -88,8 +91,10 @@ private record ChartInstallOptionsTestParameters(InstallChartOptions options, Li

@BeforeAll
static void beforeAll() {
helmClient =
HelmClient.builder().defaultNamespace("helm-client-test-ns").build();
helmClient = HelmClient.builder()
.defaultNamespace("helm-client-test-ns")
.workingDirectory(new File(".").toPath())
.build();
assertThat(helmClient).isNotNull();
}

Expand Down Expand Up @@ -359,4 +364,21 @@ void testTestChartWithOptions() {
suppressExceptions(() -> helmClient.uninstallChart(HAPROXY_RELEASE_NAME));
}
}

@Test
@DisplayName("Test Helm dependency update subcommand")
void testHelmDependencyUpdate() {
helmClient.dependencyUpdate("../charts/hedera-network");
}

@Test
@DisplayName("Test Helm dependency build subcommand failure")
void testHelmDependencyBuildFailure() {
HelmExecutionException exception =
assertThrows(HelmExecutionException.class, () -> helmClient.dependencyUpdate("../charts/not-a-chart"));
assertThat(exception.getMessage()).contains("Execution of the Helm command failed with exit code: 1");
assertThat(exception.getStdOut())
.contains(
"Error: could not find ../charts/not-a-chart: stat ../charts/not-a-chart: no such file or directory");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.helm.client.test.proxy.request.chart;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.hedera.fullstack.helm.client.execution.HelmExecutionBuilder;
import com.hedera.fullstack.helm.client.proxy.request.chart.ChartDependencyUpdateRequest;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class ChartDependencyUpdateRequestTest {
@Mock
HelmExecutionBuilder helmExecutionBuilderMock;

@Test
@DisplayName("Verify ChartDependencyUpdateRequest apply")
void testChartDependencyUpdateRequestApply() {
final ChartDependencyUpdateRequest request = new ChartDependencyUpdateRequest("mocked");
assertThat(request).isNotNull();
assertThat(request.chartName()).isEqualTo("mocked");

when(helmExecutionBuilderMock.subcommands("dependency", "update")).thenReturn(helmExecutionBuilderMock);
when(helmExecutionBuilderMock.positional("mocked")).thenReturn(helmExecutionBuilderMock);
request.apply(helmExecutionBuilderMock);
verify(helmExecutionBuilderMock, times(1)).subcommands("dependency", "update");
verify(helmExecutionBuilderMock, times(1)).positional("mocked");
}
}

0 comments on commit 61f48a9

Please sign in to comment.