Skip to content

Fixing failed unit tests which were trying to mock a static function #303

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

Merged
merged 1 commit into from
Aug 8, 2022
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 @@ -107,7 +107,7 @@ public Commit commit(File repo, String message) {
*
* @param repo the location of the repo
*/
public static Optional<Commit> getLatestCommit(File repo) {
public Optional<Commit> getLatestCommit(File repo) {
try {
Git git = getRepository(repo);
Iterable<RevCommit> revCommits = git.log()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@
*/
package org.springframework.sbm.boot.upgrade_24_25.recipes;

import org.springframework.sbm.engine.git.Commit;
import org.springframework.sbm.engine.git.GitSupport;
import org.springframework.sbm.project.resource.SbmApplicationProperties;
import org.springframework.sbm.test.RecipeIntegrationTestSupport;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.springframework.core.io.ClassPathResource;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
Expand All @@ -47,7 +45,8 @@ void generateReportTest() throws IOException {
Path resultDir = RecipeIntegrationTestSupport.getResultDir(applicationDir);
String generatedReportContent = replaceDynamicPartsInReport(resultDir.resolve("Upgrade-Spring-Boot-2.4-to-2.5.html"), resultDir);

String revision = GitSupport.getLatestCommit(resultDir.toAbsolutePath().toFile()).get().getHash();
GitSupport gitSupport = new GitSupport(new SbmApplicationProperties());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will disable the gitSupport fwir as the flag will be initialized with false here. I guess that's ok or maybe better.

String revision = gitSupport.getLatestCommit(resultDir.toAbsolutePath().toFile()).get().getHash();

String expectedReport =
getContent(new ClassPathResource("/expected-report").getFile().toPath())
Expand All @@ -70,5 +69,4 @@ private String getContent(Path report) throws IOException {
Charset charset = StandardCharsets.UTF_8;
return new String(Files.readAllBytes(report), charset).replaceAll("\n$", "");
}

}