Skip to content

Commit 8e58905

Browse files
feature: add trackers upload API test
There is an issue that the post routine keep waiting forever. Upload 3 URL. The test should always return with true.
1 parent 84b70de commit 8e58905

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

source/test/test_newtrackon.pas

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ TTestNewTrackon = class(TTestCase)
1818
procedure SetUp; override;
1919
procedure TearDown; override;
2020
published
21-
procedure Test_DownloadAPI;
21+
procedure Test_API_Download;
22+
procedure Test_API_Upload;
2223
end;
2324

2425
implementation
2526

26-
procedure TTestNewTrackon.Test_DownloadAPI;
27+
procedure TTestNewTrackon.Test_API_Download;
2728
begin
2829
Check(FNewTrackon.DownloadEverything, 'Download the newtrackon API');
2930

@@ -46,6 +47,29 @@ procedure TTestNewTrackon.Test_DownloadAPI;
4647
'TrackerList_Dead should never be empty');
4748
end;
4849

50+
procedure TTestNewTrackon.Test_API_Upload;
51+
var
52+
TrackerList: TStringList;
53+
TrackersSendCount: integer;
54+
begin
55+
TrackerList := TStringList.Create;
56+
57+
//Add two trackers
58+
TrackerList.Add('udp://tracker.leechers-paradise.org:6969/announce');
59+
TrackerList.Add('udp://tracker.test.org:6969/announce');//dummy URL
60+
TrackerList.Add('wss://tracker.openwebtorrent.com');
61+
62+
//Test if upload is OK
63+
try
64+
Check(FNewTrackon.SubmitTrackers(TrackerList, TrackersSendCount),
65+
'Upload the newtrackon API');
66+
Check(TrackersSendCount <= TrackerList.Count, 'TrackersSendCount have too high value');
67+
finally
68+
TrackerList.Free;
69+
end;
70+
71+
end;
72+
4973
procedure TTestNewTrackon.SetUp;
5074
begin
5175
FNewTrackon := TNewTrackon.Create;

0 commit comments

Comments
 (0)