Skip to content

Commit

Permalink
Qute: fix unsatisfied exception when recording rendered results is off
Browse files Browse the repository at this point in the history
  • Loading branch information
mkouba committed Sep 6, 2024
1 parent 441c98d commit 3d45c9b
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 3d45c9b

Please sign in to comment.