From c3c9267f36f33c84e1373a5a7709608df2cf3165 Mon Sep 17 00:00:00 2001 From: Ara Ghukasyan Date: Mon, 29 Jan 2024 22:55:34 -0500 Subject: [PATCH] add convert to tfvar test --- .../cloud_resource_manager/core_test.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/covalent_tests/cloud_resource_manager/core_test.py b/tests/covalent_tests/cloud_resource_manager/core_test.py index 7fdca350d..569330c9b 100644 --- a/tests/covalent_tests/cloud_resource_manager/core_test.py +++ b/tests/covalent_tests/cloud_resource_manager/core_test.py @@ -652,6 +652,27 @@ def test_crm_get_resource_status(mocker, crm): mock_terraform_error_validator.assert_called_once() +def test_crm_convert_to_tfvar(mocker, crm): + """ + Unit test for CloudResourceManager._convert_to_tfvar() method. + + Test conversion outcomes. + """ + _values_map = { + # Convenient test case (not valid Terraform): + (1, False, None, "covalent321"): '[1, false, null, "covalent321"]', + # Usual test cases: + True: "true", + False: "false", + None: "null", + "covalent123": '"covalent123"', # must include quotes + 16: "16", + } + + for _value, _expected in _values_map.items(): + assert crm._convert_to_tfvar(_value) == _expected + + def test_no_git(crm, mocker): """ Test for exit with status 1 if `git` is not available.