mirror of
https://github.com/ditkrg/todo-to-issue-action.git
synced 2026-01-22 22:06:43 +00:00
test: add additional test demonstrating current bug
Added a test which demonstrates a current bug where if multiple TODOs with the same title appear in the diff of the same file, only one of those issues will have its URL succesfully inserted. (Specifically, the first from the top.) As such, the test is configured as an expected failure until such time as the bug can be fixed.
This commit is contained in:
parent
61cb584226
commit
325fbaf03b
@ -9,7 +9,7 @@ from TodoParser import TodoParser
|
|||||||
from main import process_diff
|
from main import process_diff
|
||||||
|
|
||||||
|
|
||||||
class IssueUrlInsertionTestBase(unittest.TestCase):
|
class ProcessDiffTestBase(unittest.TestCase):
|
||||||
orig_cwd = None
|
orig_cwd = None
|
||||||
tempdir = None
|
tempdir = None
|
||||||
diff_file = None
|
diff_file = None
|
||||||
@ -37,6 +37,16 @@ class IssueUrlInsertionTestBase(unittest.TestCase):
|
|||||||
# change to the simulated filesystem directory
|
# change to the simulated filesystem directory
|
||||||
os.chdir(self.tempdir.name)
|
os.chdir(self.tempdir.name)
|
||||||
|
|
||||||
|
def _standardTest(self, expected_count):
|
||||||
|
# create object to hold output
|
||||||
|
output = io.StringIO()
|
||||||
|
# process the diffs
|
||||||
|
process_diff(diff=self.diff_file, insert_issue_urls=True, parser=self.parser, output=output)
|
||||||
|
# make sure the number of issue URL comments inserted is as expected
|
||||||
|
self.assertEqual(output.getvalue().count('Issue URL successfully inserted'),
|
||||||
|
expected_count,
|
||||||
|
msg='\nProcessing log\n--------------\n'+output.getvalue())
|
||||||
|
|
||||||
def _tearDown(self):
|
def _tearDown(self):
|
||||||
# return to original working directory to ensure we don't mess up other tests
|
# return to original working directory to ensure we don't mess up other tests
|
||||||
os.chdir(self.orig_cwd)
|
os.chdir(self.orig_cwd)
|
||||||
@ -46,7 +56,7 @@ class IssueUrlInsertionTestBase(unittest.TestCase):
|
|||||||
self.tempdir = None
|
self.tempdir = None
|
||||||
|
|
||||||
|
|
||||||
class IssueUrlInsertionTest(IssueUrlInsertionTestBase):
|
class IssueUrlInsertionTest(ProcessDiffTestBase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
return super()._setUp('test_new.diff')
|
return super()._setUp('test_new.diff')
|
||||||
|
|
||||||
@ -56,12 +66,18 @@ class IssueUrlInsertionTest(IssueUrlInsertionTestBase):
|
|||||||
@unittest.skipIf(os.getenv('SKIP_PROCESS_DIFF_TEST', 'false') == 'true',
|
@unittest.skipIf(os.getenv('SKIP_PROCESS_DIFF_TEST', 'false') == 'true',
|
||||||
"Skipping because 'SKIP_PROCESS_DIFF_TEST' is 'true'")
|
"Skipping because 'SKIP_PROCESS_DIFF_TEST' is 'true'")
|
||||||
def test_url_insertion(self):
|
def test_url_insertion(self):
|
||||||
# create object to hold output
|
self._standardTest(80)
|
||||||
output = io.StringIO()
|
|
||||||
# process the diffs
|
def tearDown(self):
|
||||||
process_diff(diff=self.diff_file, insert_issue_urls=True, parser=self.parser, output=output)
|
return super()._tearDown()
|
||||||
# make sure the number of issue URL comments inserted is as expected
|
|
||||||
self.assertEqual(output.getvalue().count('Issue URL successfully inserted'), 80)
|
class IdenticalTodoTest(ProcessDiffTestBase):
|
||||||
|
def setUp(self):
|
||||||
|
return super()._setUp('test_same_title_in_same_file.diff')
|
||||||
|
|
||||||
|
@unittest.expectedFailure
|
||||||
|
def test_same_title_in_same_file(self):
|
||||||
|
self._standardTest(5)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
return super()._tearDown()
|
return super()._tearDown()
|
||||||
|
|||||||
27
tests/test_same_title_in_same_file.diff
Normal file
27
tests/test_same_title_in_same_file.diff
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
diff --git a/Counter.sol b/Counter.sol
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..d340f6a
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/Counter.sol
|
||||||
|
@@ -0,0 +1,21 @@
|
||||||
|
+contract Counter {
|
||||||
|
+ // TODO: Test this
|
||||||
|
+ // Do it
|
||||||
|
+ // labels: urgent
|
||||||
|
+
|
||||||
|
+ /// TODO: Natspec comment
|
||||||
|
+ /// Do it
|
||||||
|
+ /// labels: urgent
|
||||||
|
+
|
||||||
|
+ /*
|
||||||
|
+ TODO: Test this too
|
||||||
|
+ Do it ASAP
|
||||||
|
+ labels: urgent
|
||||||
|
+ */
|
||||||
|
+
|
||||||
|
+ // TODO: Test this
|
||||||
|
+ /**
|
||||||
|
+ * TODO: Test this too
|
||||||
|
+ * labels: urgent
|
||||||
|
+ */
|
||||||
|
+}
|
||||||
Loading…
Reference in New Issue
Block a user