Skip to content

Commit

Permalink
- F InlineOptions.automatic()
Browse files Browse the repository at this point in the history
  • Loading branch information
LarsEckart committed May 6, 2024
1 parent 0a6de8e commit 31b23fd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ public void testReportingCode()
void testEmptyLineAtTheEnd()
{
var expected = """
Jeff Jeffty Jeff
born on Jeffteen of Jeff, Nineteen-eighty-Jeff
""";
Approvals.verify(greet("Jeff"), new Options().inline(expected));
Jeff Jeffty Jeff
born on Jeffteen of Jeff, Nineteen-eighty-Jeff
""";
Approvals.verify(greet("Jeff"), new Options().inline(expected, InlineOptions.automatic()));
}
private String greet(String name)
{
Expand All @@ -128,4 +128,4 @@ private String greet(String name)
""".formatted(name, name, name, name, name, name);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.approvaltests.inline;

import org.approvaltests.core.Options;
import org.approvaltests.reporters.AutoApproveReporter;

public interface InlineOptions
{
Expand All @@ -9,25 +10,15 @@ public static InlineOptions showCode(boolean doShowCode)
{
if (doShowCode)
{
return new ShowCodeInlineOptions();
return options -> options.withReporter(new InlineJavaReporter(options.getReporter()));
}
else
{
return new DoNotShowCodeInlineOptions();
return options -> options;
}
}
public static class ShowCodeInlineOptions implements InlineOptions
public static InlineOptions automatic()
{
public Options apply(Options options)
{
return options.withReporter(new InlineJavaReporter(options.getReporter()));
}
}
public static class DoNotShowCodeInlineOptions implements InlineOptions
{
public Options apply(Options options)
{
return options;
}
return options -> options.withReporter(new InlineJavaReporter(new AutoApproveReporter()));
}
}

0 comments on commit 31b23fd

Please sign in to comment.