Skip to content

Commit

Permalink
. t remove duplication
Browse files Browse the repository at this point in the history
Co-Authored-By: Llewellyn Falco <[email protected]>
  • Loading branch information
LarsEckart and isidore committed Oct 23, 2023
1 parent 47e90e4 commit ce041e3
Showing 1 changed file with 24 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
package org.approvaltests.reporters;

import org.junit.jupiter.api.Test;
import org.lambda.functions.Function1;
import org.lambda.functions.Function2;
import org.lambda.query.Queryable;

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

class IntelliJResolverTest
{
@Test
void testFindItOnMac()
{
String userHome = "Users/lars";
Queryable<String> validPaths = Queryable.as("/Applications/IntelliJ IDEA.app/Contents/MacOS/idea",
"Users/lars/Applications/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea",
"Users/lars/Applications/IntelliJ IDEA Community.app/Contents/MacOS/idea",
"Users/lars/Applications/IntelliJ IDEA Community Edition.app/Contents/MacOS/idea");
for (String path : validPaths)
{
DiffInfo diffInfo = IntelliJToolboxResolver.getDiffInfoMac(userHome, f -> f.equals(path));
assertNotEquals("", diffInfo.diffProgram, path);
class IntelliJResolverTest {
@Test
void testFindItOnMac() {
Queryable<String> validPaths = Queryable.as("/Applications/IntelliJ IDEA.app/Contents/MacOS/idea",
"Users/lars/Applications/IntelliJ IDEA Ultimate.app/Contents/MacOS/idea",
"Users/lars/Applications/IntelliJ IDEA Community.app/Contents/MacOS/idea",
"Users/lars/Applications/IntelliJ IDEA Community Edition.app/Contents/MacOS/idea");
verifyPaths(IntelliJToolboxResolver::getDiffInfoMac, "Users/lars", validPaths);
}
}
@Test
void testFindItOnLinux()
{
String userHome = "/home/lars";
Queryable<String> validPaths = Queryable.as(
"/home/lars/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/bin/idea.sh",
"/home/lars/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/bin/idea.sh");
for (String path : validPaths)
{
DiffInfo diffInfo = IntelliJToolboxResolver.getDiffInfoLinux(userHome, f -> f.equals(path));
assertNotEquals("", diffInfo.diffProgram, path);

private static void verifyPaths(Function2<String, Function1<String, Boolean>, DiffInfo> finder, String userHome, Queryable<String> validPaths) {
for (String path : validPaths) {
DiffInfo diffInfo = finder.call(userHome, f -> f.equals(path));
assertNotEquals("", diffInfo.diffProgram, path);
}
}

@Test
void testFindItOnLinux() {
Queryable<String> validPaths = Queryable.as(
"/home/lars/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/bin/idea.sh",
"/home/lars/.local/share/JetBrains/Toolbox/apps/intellij-idea-community-edition/bin/idea.sh");
verifyPaths(IntelliJToolboxResolver::getDiffInfoLinux, "/home/lars", validPaths);
}
}
}

0 comments on commit ce041e3

Please sign in to comment.