mirror of
https://github.com/esphome/esphome.git
synced 2025-11-18 15:55:46 +00:00
update tests
This commit is contained in:
@@ -58,13 +58,21 @@ def test_text_config_value_mode_set(generate_main):
|
|||||||
|
|
||||||
def test_text_config_lamda_is_set(generate_main):
|
def test_text_config_lamda_is_set(generate_main):
|
||||||
"""
|
"""
|
||||||
Test if lambda is set for lambda mode (optimized with stateless lambda)
|
Test if lambda is set for lambda mode (optimized with stateless lambda and deduplication)
|
||||||
"""
|
"""
|
||||||
# Given
|
# Given
|
||||||
|
from esphome.core import CORE
|
||||||
|
|
||||||
# When
|
# When
|
||||||
main_cpp = generate_main("tests/component_tests/text/test_text.yaml")
|
main_cpp = generate_main("tests/component_tests/text/test_text.yaml")
|
||||||
|
|
||||||
|
# Get both global and main sections to find the shared lambda definition
|
||||||
|
full_cpp = CORE.cpp_global_section + main_cpp
|
||||||
|
|
||||||
# Then
|
# Then
|
||||||
assert "it_4->set_template([]() -> esphome::optional<std::string> {" in main_cpp
|
# Lambda is deduplicated into a shared function (reference in main section)
|
||||||
assert 'return std::string{"Hello"};' in main_cpp
|
assert "it_4->set_template(shared_lambda_" in main_cpp
|
||||||
|
# Lambda body should be in the code somewhere
|
||||||
|
assert 'return std::string{"Hello"};' in full_cpp
|
||||||
|
# Verify the shared lambda function is defined (in global section)
|
||||||
|
assert "esphome::optional<std::string> shared_lambda_" in full_cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user