forked from Hithomelabs/CFTunnels
Hithomelabs/CFTunnels#88: address PR review - fix test expectations, import, and assertions
This commit is contained in:
parent
07b70e633d
commit
da2db99755
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user