Skip to content

Commit 7e0cae2

Browse files
committed
Add tests
1 parent 43d639c commit 7e0cae2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

datadog_checks_base/tests/base/checks/test_agent_check.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,3 +1316,23 @@ def test_env_var_logic_preset():
13161316
AgentCheck()
13171317
assert os.getenv('OPENSSL_CONF', None) == preset_conf
13181318
assert os.getenv('OPENSSL_MODULES', None) == preset_modules
1319+
1320+
@pytest.mark.parametrize(
1321+
"should_profile_value, expected_calls",
1322+
[
1323+
(True, 1),
1324+
(False, 0),
1325+
],
1326+
)
1327+
def test_profile_memory(should_profile_value, expected_calls):
1328+
"""
1329+
Test that profile_memory is called when should_profile_memory is True
1330+
"""
1331+
check = AgentCheck('test', {}, [{}])
1332+
check.should_profile_memory = mock.MagicMock(return_value=should_profile_value)
1333+
check.profile_memory = mock.MagicMock()
1334+
1335+
check.run()
1336+
1337+
assert check.should_profile_memory.call_count == 1
1338+
assert check.profile_memory.call_count == expected_calls

0 commit comments

Comments
 (0)