def test_store_missing_symbol_skips_bad_code_file_or_id(): # If the code_file or code_id is too long don't bother storing it. views.store_missing_symbol("foo.pdb", "ABCDEF12345", "foo.sym", code_file="x" * 200) views.store_missing_symbol("foo.pdb", "ABCDEF12345", "foo.sym", code_id="x" * 200) assert not MissingSymbol.objects.all().exists()
def test_store_missing_symbol_skips_bad_code_file_or_id(metricsmock): # If the code_file or code_id is too long don't bother storing it. views.store_missing_symbol('foo.pdb', 'ABCDEF12345', 'foo.sym', code_file='x' * 200) views.store_missing_symbol('foo.pdb', 'ABCDEF12345', 'foo.sym', code_id='x' * 200) assert not MissingSymbol.objects.all().exists()
def test_store_missing_symbol_happy_path(metricsmock): views.store_missing_symbol("foo.pdb", "ABCDEF12345", "foo.sym") missing_symbol = MissingSymbol.objects.get( symbol="foo.pdb", debugid="ABCDEF12345", filename="foo.sym", code_file__isnull=True, code_id__isnull=True, ) assert missing_symbol.hash assert missing_symbol.count == 1 first_modified_at = missing_symbol.modified_at # Repeat and it should increment views.store_missing_symbol("foo.pdb", "ABCDEF12345", "foo.sym") missing_symbol.refresh_from_db() assert missing_symbol.count == 2 assert missing_symbol.modified_at > first_modified_at records = metricsmock.get_records() assert len(records) == 2 assert records[0][1] == "tecken.download_store_missing_symbol" assert records[1][1] == "tecken.download_store_missing_symbol" # This time with a code_file and code_id views.store_missing_symbol( "foo.pdb", "ABCDEF12345", "foo.sym", code_file="libsystem_pthread.dylib", code_id="id", ) second_missing_symbol = MissingSymbol.objects.get( symbol="foo.pdb", debugid="ABCDEF12345", filename="foo.sym", code_file="libsystem_pthread.dylib", code_id="id", ) assert second_missing_symbol.hash != missing_symbol.hash assert second_missing_symbol.count == 1
def test_store_missing_symbol_skips(): # If either symbol, debugid or filename are too long nothing is stored views.store_missing_symbol("x" * 200, "ABCDEF12345", "foo.sym") views.store_missing_symbol("foo.pdb", "x" * 200, "foo.sym") views.store_missing_symbol("foo.pdb", "ABCDEF12345", "x" * 200) assert not MissingSymbol.objects.all().exists()
def test_store_missing_symbol_skips(metricsmock): # If either symbol, debugid or filename are too long nothing is stored views.store_missing_symbol('x' * 200, 'ABCDEF12345', 'foo.sym') views.store_missing_symbol('foo.pdb', 'x' * 200, 'foo.sym') views.store_missing_symbol('foo.pdb', 'ABCDEF12345', 'x' * 200) assert not MissingSymbol.objects.all().exists()