Hithomelabs/CFTunnels#88: address PR review - fix test expectations, import, and assertions
All checks were successful
sample gradle build and test / build (pull_request) Successful in 1m52s
sample gradle build and test / tag (push) Successful in 6s
sample gradle build and test / build_tag_push (push) Successful in 2m19s
Daily cloudflare API integration test / cloudflare-api-test (push) Successful in 1m54s
Promote image with tag test to prod / tag (push) Successful in 10s
Promote image with tag test to prod / build_tag_push (push) Successful in 19s

This commit is contained in:
hitanshu310 2026-07-06 23:49:12 +05:30
parent 07b70e633d
commit da2db99755
3 changed files with 9 additions and 8 deletions

View File

@ -2,6 +2,7 @@ package com.hithomelabs.common.portainer.client;
import com.hithomelabs.common.portainer.client.exception.PortainerAuthenticationException;
import com.hithomelabs.common.portainer.client.exception.PortainerConnectionException;
import com.hithomelabs.common.portainer.client.exception.PortainerDeploymentException;
import com.hithomelabs.common.portainer.client.exception.PortainerResourceNotFoundException;
import com.hithomelabs.common.portainer.model.EnvVariable;
import com.hithomelabs.common.portainer.model.PortainerAuthRequest;
@ -254,7 +255,7 @@ class PortainerApiClientTest {
@Test
void getStack_nullId_throwsException() {
assertThrows(com.hithomelabs.common.portainer.client.exception.PortainerDeploymentException.class,
assertThrows(PortainerDeploymentException.class,
() -> client.getStack(null));
verifyNoInteractions(restTemplate);
}
@ -417,14 +418,14 @@ class PortainerApiClientTest {
@Test
void redeployGitStack_nullId_throwsException() {
assertThrows(com.hithomelabs.common.portainer.client.exception.PortainerDeploymentException.class,
assertThrows(PortainerDeploymentException.class,
() -> client.redeployGitStack(null, 2L, true, null));
verifyNoInteractions(restTemplate);
}
@Test
void redeployGitStack_nullEndpointId_throwsException() {
assertThrows(com.hithomelabs.common.portainer.client.exception.PortainerDeploymentException.class,
assertThrows(PortainerDeploymentException.class,
() -> client.redeployGitStack(1L, null, true, null));
verifyNoInteractions(restTemplate);
}
@ -498,7 +499,7 @@ class PortainerApiClientTest {
anyLong()))
.thenReturn(responseEntity);
assertThrows(com.hithomelabs.common.portainer.client.exception.PortainerDeploymentException.class,
assertThrows(PortainerDeploymentException.class,
() -> client.redeployGitStack(1L, 2L, true, null));
}
}

View File

@ -29,14 +29,14 @@ class EnvVariableTest {
void nullName() throws JsonProcessingException {
EnvVariable env = new EnvVariable(null, "value");
String json = mapper.writeValueAsString(env);
assertTrue(json.contains("\"value\":\"value\""));
assertEquals("{\"name\":null,\"value\":\"value\"}", json);
}
@Test
void nullValue() throws JsonProcessingException {
EnvVariable env = new EnvVariable("name", null);
String json = mapper.writeValueAsString(env);
assertTrue(json.contains("\"name\":\"name\""));
assertEquals("{\"name\":\"name\",\"value\":null}", json);
}
@Test

View File

@ -61,8 +61,8 @@ class DeployServiceTest {
deployService.redeploy(STACK_ID);
verify(portainerApiClient).getStack(STACK_ID);
// When getEnv() returns null, null is passed to redeployGitStack no NPE
verify(portainerApiClient).redeployGitStack(STACK_ID, ENDPOINT_ID, true, null);
// When getEnv() returns null, an empty list is passed to redeployGitStack
verify(portainerApiClient).redeployGitStack(STACK_ID, ENDPOINT_ID, true, List.of());
}
@Test