Skip to content

Commit 04f4122

Browse files
committed
Add tests for models
Signed-off-by: Tushar Goel <[email protected]>
1 parent e6cc9b7 commit 04f4122

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

scanpipe/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,8 +1948,8 @@ def has_directory_content_fingerprint(self):
19481948

19491949
def elfs(self):
19501950
"""
1951-
Resources that are ``files`` and their filetype startswith `elf` and contains any of thes
1952-
`executable`, `relocatable`, `shared object`.
1951+
Resources that are ``files`` and their filetype startswith `elf` and
1952+
contains any of these `executable`, `relocatable`, `shared object`.
19531953
"""
19541954
return (
19551955
self.files()

scanpipe/tests/test_models.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,6 +2110,45 @@ def test_scanpipe_codebase_resource_queryset_has_directory_content_fingerprint(
21102110
results = self.project1.codebaseresources.has_directory_content_fingerprint()
21112111
self.assertQuerySetEqual(expected, results, ordered=False)
21122112

2113+
def test_scanpipe_codebase_resource_elfs(self):
2114+
project = Project.objects.create(name="Test")
2115+
CodebaseResource.objects.create(
2116+
file_type="""ELF 32-bit LSB executable, ARM, version 1 (ARM), statically
2117+
linked, with debug_info, not stripped""",
2118+
project=project,
2119+
path="a",
2120+
type=CodebaseResource.Type.FILE,
2121+
)
2122+
CodebaseResource.objects.create(
2123+
file_type="""32-bit LSB executable, ARM, version 1 (ARM), statically
2124+
linked, with debug_info, not stripped""",
2125+
project=project,
2126+
path="b",
2127+
type=CodebaseResource.Type.FILE,
2128+
)
2129+
CodebaseResource.objects.create(
2130+
file_type="""ELF 32-bit LSB resourcable, ARM, version 1 (ARM), statically
2131+
linked, with debug_info, not stripped""",
2132+
project=project,
2133+
path="c",
2134+
type=CodebaseResource.Type.FILE,
2135+
)
2136+
CodebaseResource.objects.create(
2137+
file_type="""32-bit LSB relocatable, ARM, version 1 (ARM), statically
2138+
linked, with debug_info, not stripped""",
2139+
project=project,
2140+
path="d",
2141+
type=CodebaseResource.Type.FILE,
2142+
)
2143+
CodebaseResource.objects.create(
2144+
file_type="""ELF 32-bit LSB relocatable, ARM, version 1 (ARM), statically
2145+
linked, with debug_info, not stripped""",
2146+
project=project,
2147+
path="e",
2148+
type=CodebaseResource.Type.FILE,
2149+
)
2150+
self.assertEqual(2, project.codebaseresources.elfs().count())
2151+
21132152

21142153
class ScanPipeModelsTransactionTest(TransactionTestCase):
21152154
"""

0 commit comments

Comments
 (0)