Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue Fix #2601 : Fix windows tests in jkube-kit/build/api module #2629

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import static org.apache.commons.io.FilenameUtils.separatorsToSystem;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;

Expand Down Expand Up @@ -105,8 +106,8 @@ void withoutDockerfile() throws IOException {
assertBuildDirectoryFileTree("test-image").containsExactlyInAnyOrder(
"Dockerfile",
"jkube-generated-layer-final-artifact",
"jkube-generated-layer-final-artifact/maven",
"jkube-generated-layer-final-artifact/maven/test-0.1.0.jar",
separatorsToSystem("jkube-generated-layer-final-artifact/maven"),
separatorsToSystem("jkube-generated-layer-final-artifact/maven/test-0.1.0.jar"),
"maven"
);
}
Expand Down Expand Up @@ -136,8 +137,8 @@ void withoutDockerfileAndFinalCustomizer() throws IOException {
assertBuildDirectoryFileTree("no-docker-file-and-customizer").containsExactlyInAnyOrder(
"Dockerfile",
"jkube-generated-layer-final-artifact",
"jkube-generated-layer-final-artifact/maven",
"jkube-generated-layer-final-artifact/maven/test-0.1.0.jar",
separatorsToSystem("jkube-generated-layer-final-artifact/maven"),
separatorsToSystem("jkube-generated-layer-final-artifact/maven/test-0.1.0.jar"),
"maven");
assertThat(customized).isTrue();
}
Expand Down Expand Up @@ -166,8 +167,8 @@ void withoutDockerfileAndAlreadyExistingFileInAssemblyGetsOverwritten() throws I
assertBuildDirectoryFileTree("modified-image").containsExactlyInAnyOrder(
"Dockerfile",
"jkube-generated-layer-final-artifact",
"jkube-generated-layer-final-artifact/maven",
"jkube-generated-layer-final-artifact/maven/test-0.1.0.jar",
separatorsToSystem("jkube-generated-layer-final-artifact/maven"),
separatorsToSystem("jkube-generated-layer-final-artifact/maven/test-0.1.0.jar"),
"maven");
assertThat(resolveDockerBuild("modified-image")
.resolve("jkube-generated-layer-final-artifact").resolve("maven").resolve("test-0.1.0.jar"))
Expand Down Expand Up @@ -197,10 +198,10 @@ void withDockerfileInBaseDirectory() throws IOException {
assertBuildDirectoryFileTree("test-image").containsExactlyInAnyOrder(
"Dockerfile",
"maven",
"maven/Dockerfile",
"maven/test-0.1.0.jar",
"maven/target",
"maven/target/test-0.1.0.jar");
separatorsToSystem("maven/Dockerfile"),
separatorsToSystem("maven/test-0.1.0.jar"),
separatorsToSystem("maven/target"),
separatorsToSystem("maven/target/test-0.1.0.jar"));
}

@Test
Expand Down Expand Up @@ -238,11 +239,11 @@ void withDockerfileInBaseDirectoryAndAssemblyFile() throws IOException {
assertBuildDirectoryFileTree("dockerfile-and-assembly-file").containsExactlyInAnyOrder(
"Dockerfile",
"maven",
"maven/Dockerfile",
"maven/test-0.1.0.jar",
"maven/extra-file-1.txt",
"maven/target",
"maven/target/test-0.1.0.jar");
separatorsToSystem("maven/Dockerfile"),
separatorsToSystem("maven/test-0.1.0.jar"),
separatorsToSystem("maven/extra-file-1.txt"),
separatorsToSystem("maven/target"),
separatorsToSystem("maven/target/test-0.1.0.jar"));
}

@Test
Expand Down Expand Up @@ -271,9 +272,9 @@ void withDockerfileInBaseDirectoryAndDockerinclude() throws IOException {
assertBuildDirectoryFileTree("test-image").containsExactlyInAnyOrder(
"Dockerfile",
"maven",
"maven/test-0.1.0.jar",
"maven/target",
"maven/target/ill-be-included.txt");
separatorsToSystem("maven/test-0.1.0.jar"),
separatorsToSystem("maven/target"),
separatorsToSystem("maven/target/ill-be-included.txt"));
}

@Test
Expand Down Expand Up @@ -302,11 +303,12 @@ void withDockerfileInBaseDirectoryAndDockerexclude() throws IOException {
assertBuildDirectoryFileTree("test-image").containsExactlyInAnyOrder(
"Dockerfile",
"maven",
"maven/Dockerfile",
"maven/test-0.1.0.jar",
"maven/target",
"maven/target/test-0.1.0.jar",
"maven/target/ill-be-included");
separatorsToSystem("maven/Dockerfile"),
separatorsToSystem("maven/test-0.1.0.jar"),
separatorsToSystem("maven/target"),
separatorsToSystem("maven/target/test-0.1.0.jar"),
separatorsToSystem("maven/target/ill-be-included")
);
}

@Test
Expand Down Expand Up @@ -335,11 +337,11 @@ void withDockerfileInBaseDirectoryAndDockerignore() throws IOException {
assertBuildDirectoryFileTree("test-image").containsExactlyInAnyOrder(
"Dockerfile",
"maven",
"maven/Dockerfile",
"maven/test-0.1.0.jar",
"maven/target",
"maven/target/test-0.1.0.jar",
"maven/target/i-wont-be-ignored");
separatorsToSystem("maven/Dockerfile"),
separatorsToSystem("maven/test-0.1.0.jar"),
separatorsToSystem("maven/target"),
separatorsToSystem("maven/target/test-0.1.0.jar"),
separatorsToSystem("maven/target/i-wont-be-ignored"));
}

private void assertTargetHasDockerDirectories(String imageDirName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.nio.file.Path;
import java.util.Base64;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;

import com.fasterxml.jackson.core.type.TypeReference;
Expand Down Expand Up @@ -127,7 +128,7 @@ private void createOpenShiftConfig(File homeDir, String testConfig) {
File kubeDir = new File(homeDir, ".kube");
kubeDir.mkdirs();
File config = new File(kubeDir, "config");
IOUtils.copy(getClass().getResourceAsStream(testConfig), new FileOutputStream(config));
Files.copy(new File(Objects.requireNonNull(getClass().getResource(testConfig)).getFile()).toPath(), config.toPath());
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void interpolate_withNullFilter_shouldPickDefaultFilter() throws IOException {
String result = DockerFileUtil.interpolate(givenDockerfile, properties, null);

// Then
String[] lines = result.split("\n");
String[] lines = result.split(System.lineSeparator());
assertThat(result).isNotNull();
assertThat(lines).hasSize(2)
.containsExactly("FROM openjdk:latest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.assertj.core.error.ShouldBeEmpty;
import org.assertj.core.internal.Failures;

import static org.apache.commons.io.FilenameUtils.separatorsToSystem;
import static org.assertj.core.error.ShouldBeEqualIgnoringCase.shouldBeEqual;

public class ArchiveAssertions extends AbstractFileAssert<ArchiveAssertions> {
Expand Down Expand Up @@ -126,8 +127,8 @@ public ArchiveAssertions hasSameContentAsDirectory(File directory) throws IOExce
final List<String> actualEntries = new ArrayList<>();
processArchive(actual, (entry, tis) -> {
// Remove last separator for directory entries -> Required for fileTree assertion
actualEntries.add(entry.isDirectory() ?
entry.getName().substring(0, entry.getName().length() - 1) : entry.getName());
actualEntries.add(separatorsToSystem(entry.isDirectory() ?
entry.getName().substring(0, entry.getName().length() - 1) : entry.getName()));
final File expected = new File(directory, entry.getName());
if (!expected.exists()) {
throw failures.failure(info, new BasicErrorMessageFactory("%nExpecting archive <%s>%nnot to contain entry:%n <%s>%n",
Expand Down
Loading