Skip to content

Commit

Permalink
Merge pull request #43095 from mkouba/qute-fix-renderedresults
Browse files Browse the repository at this point in the history
Qute: fix unsatisfied exception when recording rendered results is off
  • Loading branch information
gsmet authored Sep 7, 2024
2 parents 8530dc9 + 3d45c9b commit 07b451f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.qute.deployment.test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import jakarta.enterprise.inject.Instance;
Expand All @@ -10,6 +11,7 @@
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkus.qute.RenderedResults;
import io.quarkus.qute.Template;
import io.quarkus.test.QuarkusUnitTest;

public class RenderedResultsDisabledTest {
Expand All @@ -25,9 +27,13 @@ public class RenderedResultsDisabledTest {
@Inject
Instance<RenderedResults> renderedResults;

@Inject
Template foo;

@Test
public void testRenderedResultsNotRegistered() {
assertTrue(renderedResults.isUnsatisfied());
assertEquals("Morna", foo.data("name", "Morna").render());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public class TemplateProducer {
templateVariants.put(entry.getKey(), var);
}
this.templateVariants = Collections.unmodifiableMap(templateVariants);
this.renderedResults = launchMode == LaunchMode.TEST ? renderedResults.get() : null;
this.renderedResults = launchMode == LaunchMode.TEST && renderedResults.isResolvable() ? renderedResults.get() : null;
this.injectedTemplates = launchMode == LaunchMode.DEVELOPMENT ? Collections.synchronizedList(new ArrayList<>()) : null;
LOGGER.debugf("Initializing Qute variant templates: %s", templateVariants);
}
Expand Down

0 comments on commit 07b451f

Please sign in to comment.