Skip to content

Commit 56669de

Browse files
Add test for ruby d2d mapping
Signed-off-by: Ayan Sinha Mahapatra <[email protected]>
1 parent 7bdb1b6 commit 56669de

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
55 KB
Binary file not shown.
10.5 KB
Binary file not shown.

scanpipe/tests/pipes/test_d2d.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
from scanpipe.models import CodebaseResource
3737
from scanpipe.models import Project
3838
from scanpipe.pipes import d2d
39+
from scanpipe.pipes import d2d_config
3940
from scanpipe.pipes import flag
4041
from scanpipe.pipes import scancode
4142
from scanpipe.pipes.input import copy_input
@@ -1531,6 +1532,51 @@ def test_scanpipe_pipes_d2d_map_go_paths(self):
15311532
).count(),
15321533
)
15331534

1535+
def test_scanpipe_pipes_d2d_map_ruby(self):
1536+
input_dir = self.project1.input_path
1537+
input_resources = [
1538+
self.data / "d2d-ruby/to-sentry-delayed_job-5.22.1.gem",
1539+
self.data / "d2d-ruby/from-sentry-ruby-5.22.1.zip",
1540+
]
1541+
copy_inputs(input_resources, input_dir)
1542+
self.from_files, self.to_files = d2d.get_inputs(self.project1)
1543+
inputs_with_codebase_path_destination = [
1544+
(self.from_files, self.project1.codebase_path / d2d.FROM),
1545+
(self.to_files, self.project1.codebase_path / d2d.TO),
1546+
]
1547+
for input_files, codebase_path in inputs_with_codebase_path_destination:
1548+
for input_file_path in input_files:
1549+
scancode.extract_archive(input_file_path, codebase_path)
1550+
1551+
scancode.extract_archives(
1552+
self.project1.codebase_path,
1553+
recurse=True,
1554+
)
1555+
pipes.collect_and_create_codebase_resources(self.project1)
1556+
buffer = io.StringIO()
1557+
d2d.map_checksum(
1558+
project=self.project1, checksum_field="sha1", logger=buffer.write
1559+
)
1560+
ruby_config = d2d_config.get_ecosystem_config(ecosystem="Ruby")
1561+
d2d.ignore_unmapped_resources_from_config(
1562+
project=self.project1,
1563+
patterns_to_ignore=ruby_config.deployed_resource_path_exclusions,
1564+
logger=buffer.write,
1565+
)
1566+
d2d.flag_undeployed_resources(project=self.project1)
1567+
self.assertEqual(
1568+
39,
1569+
CodebaseRelation.objects.filter(
1570+
project=self.project1, map_type="sha1"
1571+
).count(),
1572+
)
1573+
self.assertEqual(
1574+
0,
1575+
CodebaseResource.objects.filter(
1576+
project=self.project1, status="requires-review"
1577+
).count(),
1578+
)
1579+
15341580
@skipIf(sys.platform == "darwin", "Test is failing on macOS")
15351581
def test_scanpipe_pipes_d2d_map_rust_symbols(self):
15361582
input_dir = self.project1.input_path

0 commit comments

Comments
 (0)