Skip to content
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

Qute: fix unsatisfied exception when recording rendered results is off #43095

Merged
merged 1 commit into from
Sep 7, 2024
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
@@ -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