import unittest
import time
import threading
import requests
from helper import Debugger
def make_http_request(event):
url = "http://localhost:8000"
payload = "hello from integration test"
requests.post(url, data=payload)
event.set()
class PastebinTestCase(unittest.TestCase):
def setUp(self):
self.debugger = Debugger(path='./examples/target/debug/pastebin')
def test_step_over_until_response(self):
self.debugger.cmd('b main.rs:21', 'New breakpoint')
time.sleep(3)
self.debugger.cmd_re('run', 'Configured for debug.')
event = threading.Event()
thread = threading.Thread(target=make_http_request, args=(event,))
thread.start()
time.sleep(3)
while not event.wait(0.2):
self.debugger.cmd('next', 'next')
time.sleep(0.1)
time.sleep(0.2)
thread.join()
self.debugger.control('c')
self.debugger.cmd('q')
def test_continue_until_response(self):
self.debugger.cmd('b main.rs:21', 'New breakpoint')
time.sleep(3)
self.debugger.cmd('run', 'Configured for debug.')
event = threading.Event()
thread = threading.Thread(target=make_http_request, args=(event,))
thread.start()
time.sleep(2)
self.debugger.expect_in_output('21 let id = PasteId::new(ID_LENGTH);')
self.debugger.cmd('next', '22 paste')
self.debugger.cmd('next', '22 paste')
self.debugger.cmd('next', '23 .open(128.kibibytes())')
self.debugger.cmd('next', '24 .into_file(id.file_path())')
self.debugger.cmd('next', '22 paste')
self.debugger.cmd('next', '24 .into_file(id.file_path())')
self.debugger.cmd('next', '25 .await?;')
self.debugger.cmd('continue')
thread.join()
self.debugger.control('c')
self.debugger.cmd('q')