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

#3941 move ResolveMojo tests to integration tests + divide tests into several ones #3962

Merged
merged 6 commits into from
Feb 27, 2025
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
3 changes: 1 addition & 2 deletions .codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
# package name contains capital letter and such names are conventional.
---
exclude_paths:
- "eo-maven-plugin/src/test/java/org/eolang/maven/ShakeMojoIT.java"
- "eo-maven-plugin/src/test/java/org/eolang/maven/SodgMojoIT.java"
- "eo-maven-plugin/src/test/java/org/eolang/maven/ResolveMojoIT.java"
93 changes: 93 additions & 0 deletions eo-maven-plugin/src/test/java/org/eolang/maven/ResolveMojoIT.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com
* SPDX-License-Identifier: MIT
*/
package org.eolang.maven;

import com.jcabi.manifests.Manifests;
import com.yegor256.MayBeSlow;
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.WeAreOnline;
import com.yegor256.farea.Farea;
import java.io.IOException;
import java.nio.file.Path;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

/**
* Integration tests for {@link ResolveMojo}.
*
* @since 0.52
*/
@SuppressWarnings({"JTCOP.RuleAllTestsHaveProductionClass", "JTCOP.RuleNotContainsTestWord"})
@ExtendWith({WeAreOnline.class, MktmpResolver.class, MayBeSlow.class})
final class ResolveMojoIT {

@Test
void resolvesJarFile(@Mktmp final Path temp) throws IOException {
final String version = "0.39.0";
new Farea(temp).together(
f -> {
ResolveMojoIT.configureFarea(f, version);
f.exec("process-classes");
MatcherAssert.assertThat(
"the jar file was resolved and unpacked",
f.files().file(
String.format(
"target/eo/%s/org.eolang/eo-runtime/-/%s/org/eolang/Phi.class",
ResolveMojo.DIR,
version
)
).exists(),
Matchers.is(true)
);
}
);
}

@Test
void removesOldJarFile(@Mktmp final Path temp) throws IOException {
final String version = "0.38.0";
new Farea(temp).together(
f -> {
ResolveMojoIT.configureFarea(f, version);
f.exec("process-classes");
f.dependencies()
.append("org.eolang", "eo-runtime", "0.40.0");
f.exec("process-classes");
MatcherAssert.assertThat(
"binary files from the old JAR were removed",
f.files().file(
String.format(
"target/eo/%s/org.eolang/eo-runtime/-/%s",
ResolveMojo.DIR,
version
)
).exists(),
Matchers.is(false)
);
}
);
}

private static void configureFarea(final Farea farea, final String version) throws IOException {
farea.clean();
farea.dependencies()
.append("org.eolang", "eo-runtime", version);
farea.build()
.plugins()
.append(
"org.eolang",
"eo-maven-plugin",
System.getProperty(
"eo.version",
Manifests.read("EO-Version")
)
)
.execution()
.goals("resolve");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.yegor256.Mktmp;
import com.yegor256.MktmpResolver;
import com.yegor256.WeAreOnline;
import com.yegor256.farea.Farea;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collections;
Expand Down Expand Up @@ -41,40 +40,6 @@ final class ResolveMojoTest {
*/
private static final String JAR_NOT_EXIST = "The jar file must not exist, but it doesn't";

@Test
void deletesOtherVersions(@Mktmp final Path temp) throws IOException {
new Farea(temp).together(
f -> {
f.clean();
f.dependencies()
.append("org.eolang", "eo-runtime", "0.39.0");
f.build()
.plugins()
.appendItself()
.execution()
.goals("resolve");
f.exec("process-classes");
MatcherAssert.assertThat(
"the jar file was resolved and unpacked",
f.files().file(
"target/eo/5-resolve/org.eolang/eo-runtime/-/0.39.0/org/eolang/Phi.class"
).exists(),
Matchers.is(true)
);
f.dependencies()
.append("org.eolang", "eo-runtime", "0.40.0");
f.exec("process-classes");
MatcherAssert.assertThat(
"binary files from the old JAR were removed",
f.files().file(
"target/eo/5-resolve/org.eolang/eo-runtime/-/0.39.0"
).exists(),
Matchers.is(false)
);
}
);
}

@Test
void resolvesWithSingleDependency(@Mktmp final Path temp) throws IOException {
new FakeMaven(temp)
Expand Down
Loading