dineshba / tf-summarize

A command-line utility to print the summary of the terraform plan
MIT License
534 stars 38 forks source link

Add test coverage #78

Closed kumdeepakgit closed 1 month ago

kumdeepakgit commented 1 month ago

Add test coverage for writer pkg

        github.com/dineshba/tf-summarize/reader         coverage: 0.0% of statements
=== RUN   TestVersionArg
=== RUN   TestVersionArg/when_tf-summarize_is_passed_'-v'
--- PASS: TestVersionArg (0.00s)
    --- PASS: TestVersionArg/when_tf-summarize_is_passed_'-v' (0.00s)
=== RUN   TestTFSummarize
=== RUN   TestTFSummarize/when_tf-summarize_is_passed_'"./tf-summarize-test_-md_example/tfplan.json"'
=== RUN   TestTFSummarize/when_tf-summarize_is_passed_'"cat_example/tfplan.json_|_./tf-summarize-test_-md"'
=== RUN   TestTFSummarize/when_tf-summarize_is_passed_'"cat_example/tfplan.json_|_./tf-summarize-test_-html"'
=== RUN   TestTFSummarize/when_tf-summarize_is_passed_'"cat_example/tfplan.json_|_./tf-summarize-test_-md_-html"'
--- PASS: TestTFSummarize (0.02s)
    --- PASS: TestTFSummarize/when_tf-summarize_is_passed_'"./tf-summarize-test_-md_example/tfplan.json"' (0.00s)
    --- PASS: TestTFSummarize/when_tf-summarize_is_passed_'"cat_example/tfplan.json_|_./tf-summarize-test_-md"' (0.00s)
    --- PASS: TestTFSummarize/when_tf-summarize_is_passed_'"cat_example/tfplan.json_|_./tf-summarize-test_-html"' (0.00s)
    --- PASS: TestTFSummarize/when_tf-summarize_is_passed_'"cat_example/tfplan.json_|_./tf-summarize-test_-md_-html"' (0.00s)
PASS
coverage: 0.0% of statements
ok      github.com/dineshba/tf-summarize        0.470s  coverage: 0.0% of statements
=== RUN   TestJSONParser_Parse_Success
--- PASS: TestJSONParser_Parse_Success (0.00s)
=== RUN   TestJSONParser_Parse_InvalidJSON
--- PASS: TestJSONParser_Parse_InvalidJSON (0.00s)
=== RUN   TestNewJSONParser
--- PASS: TestNewJSONParser (0.00s)
=== RUN   TestCreateParser_JSONFile
--- PASS: TestCreateParser_JSONFile (0.00s)
=== RUN   TestCreateParser_Stdin
--- PASS: TestCreateParser_Stdin (0.00s)
=== RUN   TestCreateParser_BinaryFile
--- PASS: TestCreateParser_BinaryFile (0.00s)
=== RUN   TestCreateParser_InvalidFileName
--- PASS: TestCreateParser_InvalidFileName (0.00s)
PASS
coverage: 45.5% of statements
ok      github.com/dineshba/tf-summarize/parser 0.008s  coverage: 45.5% of statements
=== RUN   TestResourceChangeColor
--- PASS: TestResourceChangeColor (0.00s)
=== RUN   TestGetAllResourceChanges
--- PASS: TestGetAllResourceChanges (0.00s)
=== RUN   TestGetAllOutputChanges
--- PASS: TestGetAllOutputChanges (0.00s)
=== RUN   TestResourceChangeSuffix
--- PASS: TestResourceChangeSuffix (0.00s)
=== RUN   TestResourceChangeColorAndSuffixImport
--- PASS: TestResourceChangeColorAndSuffixImport (0.00s)
=== RUN   TestFilterNoOpResources
--- PASS: TestFilterNoOpResources (0.00s)
PASS
coverage: 93.7% of statements
ok      github.com/dineshba/tf-summarize/terraformstate 0.008s  coverage: 93.7% of statements
=== RUN   TestCreateTreeForEmptyResourceChanges
--- PASS: TestCreateTreeForEmptyResourceChanges (0.00s)
=== RUN   TestCreateTreeForOneResourceChanges
--- PASS: TestCreateTreeForOneResourceChanges (0.00s)
=== RUN   TestCreateTreeWithQuotesInResources
--- PASS: TestCreateTreeWithQuotesInResources (0.00s)
=== RUN   TestCreateTreeForOneResourceChangesMultiLevel
--- PASS: TestCreateTreeForOneResourceChangesMultiLevel (0.00s)
=== RUN   TestCreateTreeForTwoResourceChangesNoOverlap
--- PASS: TestCreateTreeForTwoResourceChangesNoOverlap (0.00s)
=== RUN   TestCreateTreeForTwoResourceChangesOverlap
--- PASS: TestCreateTreeForTwoResourceChangesOverlap (0.00s)
PASS
coverage: 62.1% of statements
ok      github.com/dineshba/tf-summarize/tree   0.009s  coverage: 62.1% of statements
=== RUN   TestHTMLWriterWithMockFileSystem
--- PASS: TestHTMLWriterWithMockFileSystem (0.00s)
=== RUN   TestJSONWriter
--- PASS: TestJSONWriter (0.00s)
=== RUN   TestSeparateTree_Write
=== RUN   TestSeparateTree_Write/Drawable_True
=== RUN   TestSeparateTree_Write/Drawable_False
=== RUN   TestSeparateTree_Write/Error_Handling
=== RUN   TestSeparateTree_Write/Error_Handling/Write_Error
=== RUN   TestSeparateTree_Write/Error_Handling/Tree_Writer_Error
=== RUN   TestSeparateTree_Write/Error_Handling/Final_Newline_Write_Error
--- PASS: TestSeparateTree_Write (0.00s)
    --- PASS: TestSeparateTree_Write/Drawable_True (0.00s)
    --- PASS: TestSeparateTree_Write/Drawable_False (0.00s)
    --- PASS: TestSeparateTree_Write/Error_Handling (0.00s)
        --- PASS: TestSeparateTree_Write/Error_Handling/Write_Error (0.00s)
        --- PASS: TestSeparateTree_Write/Error_Handling/Tree_Writer_Error (0.00s)
        --- PASS: TestSeparateTree_Write/Error_Handling/Final_Newline_Write_Error (0.00s)
=== RUN   TestTableWriter_Write_NoMarkdown
--- PASS: TestTableWriter_Write_NoMarkdown (0.00s)
=== RUN   TestTableWriter_Write_WithMarkdown
--- PASS: TestTableWriter_Write_WithMarkdown (0.00s)
=== RUN   TestTableWriter_NoChanges
--- PASS: TestTableWriter_NoChanges (0.00s)
=== RUN   TestTreeWriter_Write_DrawableTrue
--- PASS: TestTreeWriter_Write_DrawableTrue (0.00s)
=== RUN   TestTreeWriter_Write_NonDrawable
--- PASS: TestTreeWriter_Write_NonDrawable (0.00s)
=== RUN   TestTreeWriter_Write_NonDrawable_PrintTreeError
--- PASS: TestTreeWriter_Write_NonDrawable_PrintTreeError (0.00s)
=== RUN   TestTreeWriter_Write_PrintTreeError
--- PASS: TestTreeWriter_Write_PrintTreeError (0.00s)
=== RUN   TestTreeWriter_Write_EmptyChanges
--- PASS: TestTreeWriter_Write_EmptyChanges (0.00s)
=== RUN   TestHasOutputChanges
=== RUN   TestHasOutputChanges/No_changes
=== RUN   TestHasOutputChanges/Has_changes
=== RUN   TestHasOutputChanges/All_empty
--- PASS: TestHasOutputChanges (0.00s)
    --- PASS: TestHasOutputChanges/No_changes (0.00s)
    --- PASS: TestHasOutputChanges/Has_changes (0.00s)
    --- PASS: TestHasOutputChanges/All_empty (0.00s)
=== RUN   TestRemoveANSI
=== RUN   TestRemoveANSI/String_without_ANSI_escape
=== RUN   TestRemoveANSI/String_with_ANSI_escape
=== RUN   TestRemoveANSI/String_with_multiple_ANSI_escapes
=== RUN   TestRemoveANSI/Empty_string
--- PASS: TestRemoveANSI (0.00s)
    --- PASS: TestRemoveANSI/String_without_ANSI_escape (0.00s)
    --- PASS: TestRemoveANSI/String_with_ANSI_escape (0.00s)
    --- PASS: TestRemoveANSI/String_with_multiple_ANSI_escapes (0.00s)
    --- PASS: TestRemoveANSI/Empty_string (0.00s)
PASS
coverage: 87.4% of statements
ok      github.com/dineshba/tf-summarize/writer 0.011s  coverage: 87.4% of statements
dineshba commented 1 month ago

Also, looks there is a test failure: https://github.com/dineshba/tf-summarize/actions/runs/11233918381/job/31284281419?pr=78#step:8:83

kumdeepakgit commented 1 month ago

Also, looks there is a test failure: https://github.com/dineshba/tf-summarize/actions/runs/11233918381/job/31284281419?pr=78#step:8:83

@dineshba Yes, there were some flaky test cases, have updated those