-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Add tests for Drifty #618
Comments
Hello 👋! Thank you very much for raising an issue 🙌! The maintainers will get back to you soon for discussion over the issue! 🚀Meanwhile you can also discuss about the project in our Discord Server 😀 |
hey im currently working on this issue. Is anybody already working on that? |
@JjJjJose Hi José 👋! |
@SaptarshiSarkar12 hey! it was really a pain in the head ahahaha |
@JjJjJose Great 😃. Are you testing the link type? Are you using the |
i was using indirectly, actually i was using DownloadConfiguration class. i will use the LinkType class for tests! and thank you !!! :D |
Yeah, you can use Link type class for that purpose.
That's true 😁
I hope you would enjoy working in this project on this issue gaining enough experience to work on more such big projects 😃. |
really appreciate it 😄 if you have any extra info about the link Type class feel free to comment! |
@JjJjJose The class is self explanatory, I suppose. Nothing more to tell 😄. If you don't understand any usage/method, you can comment. |
when i try to implement the class the test keeps on a infinite loop, any idea how to fix it? |
Show me the code |
hello, sorry for the delay i was busy import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import support.DownloadConfiguration;
import support.Job;
import utils.MessageBroker;
import utils.Utility;
import init.Environment;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class DownloadConfigurationTest {
private DownloadConfiguration downloadConfiguration;
private Job testJob;
private MessageBroker testMessageBroker;
@BeforeEach
public void setUp() {
testMessageBroker = new MessageBroker()
{
@Override
public void msgLinkInfo(String message)
{
System.out.println("Info: " + message);
}
@Override
public void msgLinkError(String message)
{
System.out.println("Error :" + message);
}
};
//need these things below idk why
Environment.setMessageBroker(testMessageBroker);
Utility.initializeUtility();
/* downloadConfiguration = new DownloadConfiguration("https://example.com", "/downloads", "exampleFile"); */
/**testJob = new Job("https://example.com", "/downloads", "examplefile", null);
testMessageBroker = new MessageBroker() {
// Implement necessary methods if any
};
downloadConfiguration = new DownloadConfiguration("https://example.com", "/downloads", "exampleFile");**/
}
@Test
public void testYoutubeDownload() {
// Simulate the behavior of Utility.getYtDlpMetadata
//String sampleJsonResponse = "{ \"entries\": [{ \"url\": \"https://youtube.com/video1\", \"title\": \"Video 1\" }] }";
downloadConfiguration = new DownloadConfiguration("https://www.youtube.com/video1", "/downloads", "exampleFile");
// Inject the utility instance into the DownloadConfiguration if necessary
// Assuming DownloadConfiguration uses Utility.getYtDlpMetadata internally
int statusCode = downloadConfiguration.fetchFileData();
// Verify the expected behavior
assertEquals(0, statusCode, "The status code should be 0 for successful processing.");
assertEquals(1, downloadConfiguration.getFileCount(), "The file count should be 1.");
assertEquals(1, downloadConfiguration.getFilesProcessed(), "The files processed should be 1.");
assertEquals(1, downloadConfiguration.getFileData().size(), "There should be one file data entry.");
assertEquals("https://youtube.com/video1", downloadConfiguration.getFileData().get(0).get("link"), "The link should match.");
assertEquals("Video 1.mp4", downloadConfiguration.getFileData().get(0).get("filename"), "The filename should match the expected value.");
}
@Test
public void testInstagramDownload()
{
downloadConfiguration = new DownloadConfiguration("https://instagram.com/p/abc123", "/downloads", "exampleFileITG");
int statusCode = downloadConfiguration.fetchFileData();
assertEquals(0, statusCode, "The status code should be 0 for successful processing.");
assertEquals(1, downloadConfiguration.getFileCount(), "The file count should be 1.");
assertEquals(1, downloadConfiguration.getFilesProcessed(), "The files processed should be 1.");
assertEquals(1, downloadConfiguration.getFileData().size(), "There should be one file data entry.");
assertEquals("https://instagram.com/p/abc123", downloadConfiguration.getFileData().get(0).get("link"), "The link should match.");
}
@Test
public void testSpotifyDownload()
{
downloadConfiguration = new DownloadConfiguration("https://open.spotify.com/track/abc123", "/downloads", "examplefileSPTF");
int statusCode = downloadConfiguration.fetchFileData();
assertEquals(0, statusCode, "The status code should be 0 for successful processing.");
assertEquals(1, downloadConfiguration.getFileCount(), "The file count should be 1.");
assertEquals(1, downloadConfiguration.getFilesProcessed(), "The files processed should be 1.");
assertEquals(1, downloadConfiguration.getFileData().size(), "There should be one file data entry.");
assertEquals("https://open.spotify.com/track/abc123", downloadConfiguration.getFileData().get(0).get("link"), "The link should match.");
}
@Test
public void testOtherLinkDownload()
{
downloadConfiguration = new DownloadConfiguration("https://sillynessCode.com", "/downloads", "sillyExample");
int statusCode = downloadConfiguration.fetchFileData();
assertEquals(0, statusCode, "The status code should be 0 for successful processing.");
assertEquals(1, downloadConfiguration.getFileCount(), "The file count should be 1.");
assertEquals(1, downloadConfiguration.getFilesProcessed(), "The files processed should be 1.");
assertEquals(1, downloadConfiguration.getFileData().size(), "There should be one file data entry.");
assertEquals("https://sillynessCode.com", downloadConfiguration.getFileData().get(0).get("link"), "The link should match.");
}
} |
@JjJjJose it's fine 😃. From your code, it is clear that you're mixing things up. You are testing You can check this branch to get more idea about the point I'm emphasising. The branch hasn't been updated for a long time and is just a trial of how tests can be integrated in this project. I hope it helps you in understanding the procedure I mentioned. Please let me know if you have understood this or have any question. |
oh that helps a lot thanks man! |
Happy to see that my trials are of some help to you 😁.
@JjJjJose It's fine 🙂. I should have told earlier 😅.
Alright 👍. |
@JjJjJose How far did you progress? Have you faced any problem? Please let me know 😃. |
@SaptarshiSarkar12 im studyng for some exams and didnt have time progress it properly, i will look it eventually. sorry |
@JjJjJose It's okay. You can take your time. All the best for your exam 😄. |
@JjJjJose Did your exam finish? If yes, how was your exam? |
@JjJjJose Please reply. Did you encounter any problems? |
Is your feature request related to a problem? Please describe.
It is a tedious task to check if Drifty can still download all the supported types of files like YouTube, and Instagram videos and Spotify songs along with general files like
https://download.oracle.com/java/22/latest/jdk-22_linux-x64_bin.deb
.Describe the solution you'd like.
Adding multiple separate JUnit tests (I suppose this would suffice; If you think integration testing would be better in some scenario, please let me know) for each download category, batch processing, etc. would be better. Moreover, these tests can then be run on schedule via GitHub Actions allowing automated testing.
Additional information
If anyone wants to work on this issue, please comment below. I would assign this task to you.
The text was updated successfully, but these errors were encountered: