Example #1
0
    def test_local_show_resources(self):
        local_tfstate_controller = LocalTfStateController(self.existing_file)
        captured_output = io.StringIO()
        sys.stdout = captured_output
        local_tfstate_controller.show_resources()

        self.assertEqual(captured_output.getvalue().replace('\n', ''),
                         self.print_table_output)
Example #2
0
    def test_local_show_resources_not_matching_module_filter(self):
        local_tfstate_controller = LocalTfStateController(
            file_location=self.existing_file, module_filter_expression="Test")
        captured_output = io.StringIO()
        sys.stdout = captured_output
        local_tfstate_controller.show_resources()

        self.assertEqual(captured_output.getvalue().replace('\n', ''), '')
Example #3
0
    def test_local_create_html_file(self):
        local_tfstate_controller = LocalTfStateController(self.existing_file)
        local_tfstate_controller.create_html_file()

        with open('.tflens/terraform.tfstate.html', 'r') as html_file:
            html_file_content = html_file.read()

        self.assertEqual(html_file_content.replace('\n', ''),
                         self.file_htmltable_output)
Example #4
0
    def test_local_create_markdown_file(self):
        local_tfstate_controller = LocalTfStateController(self.existing_file)
        local_tfstate_controller.create_markdown_file()

        with open('.tflens/terraform.tfstate.md', 'r') as markdown_file:
            markdown_file_content = markdown_file.read()

        self.assertEqual(markdown_file_content.replace('\n', ''),
                         self.print_table_output)
Example #5
0
    def test_local_show_resources_matching_provider_filter(self):
        local_tfstate_controller = LocalTfStateController(
            file_location=self.existing_file, provider_filter_expression="aws")
        captured_output = io.StringIO()
        sys.stdout = captured_output
        local_tfstate_controller.show_resources()

        self.assertEqual(captured_output.getvalue().replace('\n', ''),
                         self.print_table_output)
Example #6
0
    def test_local_show_resources_not_matching_mixed_filter(self):
        local_tfstate_controller = LocalTfStateController(
            file_location=self.existing_file,
            module_filter_expression="test",
            name_filter_expression="current_user",
            type_filter_expression="aws_caller_identity",
            provider_filter_expression="aws",
            mode_filter_expression="Data")
        captured_output = io.StringIO()
        sys.stdout = captured_output
        local_tfstate_controller.show_resources()

        self.assertEqual(captured_output.getvalue().replace('\n', ''), '')
Example #7
0
 def test_local_tfstate_controller(self):
     LocalTfStateController(self.existing_file)