Skip to content

Commit

Permalink
review: pod ephemeral container operations
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Feb 13, 2023
1 parent ecafb22 commit a1b2616
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
5 changes: 5 additions & 0 deletions junit/kubernetes-server-mock/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@
<artifactId>junit-jupiter-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,23 @@
package io.fabric8.kubernetes.client.server.mock;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import static org.junit.jupiter.api.Assertions.assertEquals;

class StatusMessageTest {

@Test
void exitCode() {
void successExitCode() {
assertEquals("\u0003{\"apiVersion\":\"v1\",\"kind\":\"Status\",\"code\":0,\"status\":\"Success\"}",
new StatusMessage(0).getBody());
assertEquals("\u0003{\"apiVersion\":\"v1\",\"kind\":\"Status\",\"code\":1,\"status\":\"Failure\"}",
new StatusMessage(1).getBody());
assertEquals("\u0003{\"apiVersion\":\"v1\",\"kind\":\"Status\",\"code\":-1,\"status\":\"Failure\"}",
new StatusMessage(-1).getBody());
}

@ParameterizedTest(name = "exitCode, with code = ''{0}'', should create valid HTTP body")
@ValueSource(ints = { 1, -1 })
void exitCode(int exitCode) {
assertEquals("\u0003{\"apiVersion\":\"v1\",\"kind\":\"Status\",\"code\":" + exitCode + ",\"status\":\"Failure\"}",
new StatusMessage(exitCode).getBody());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ void testAttachWithWritingOutput() throws InterruptedException, IOException {
.andEmit(new WebSocketMessage(0L, "\u0002" + expectedError, false, true)) // \u0002 is the file descriptor for stderr
.always()
.expect("\u0000" + shutdownInput)
.andEmit(new StatusMessage(-1))
.andEmit(new WebSocketMessage(0L, "\u0003shutdown", false, true))
.always()
.done()
.always();
Expand Down Expand Up @@ -491,7 +491,6 @@ void testAttachWithWritingOutput() throws InterruptedException, IOException {
assertTrue(latch.await(1, TimeUnit.MINUTES));

// Then
assertEquals(-1, watch.exitCode().join());
assertEquals(expectedOutput, stdout.toString());
assertEquals(expectedError, stderr.toString());

Expand Down

0 comments on commit a1b2616

Please sign in to comment.