add tests for Arch

This commit is contained in:
Thomas Rubini 2022-12-13 09:07:32 +01:00
parent c3e55395aa
commit 3b558c2caf
No known key found for this signature in database
GPG Key ID: C7D287C8C1CAC373

View File

@ -0,0 +1,60 @@
package fr.packageviewer;
import fr.packageviewer.distribution.ArchDistribution;
import fr.packageviewer.distribution.Distribution;
import fr.packageviewer.pack.Package;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.concurrent.ExecutionException;
public class ArchTest {
@Test
public void testBasicQueryDoNotFail(){
Distribution arch = new ArchDistribution();
arch.getPackageTree("bash", 0);
}
@Test
public void testBashPackageHasNameBash() throws ExecutionException, InterruptedException {
Distribution arch = new ArchDistribution();
Package pack = arch.getPackageTree("bash", 0).get();
Assertions.assertEquals(pack.getName(), "bash");
}
@Test
public void testQueryWithDepth0HasNoDeps() throws ExecutionException, InterruptedException {
Distribution arch = new ArchDistribution();
Package pack = arch.getPackageTree("bash", 0).get();
Assertions.assertEquals(pack.getDeps().size(), 0);
}
@Test
public void testQueryWithDepth1hasOneLevelOfDeps() throws ExecutionException, InterruptedException {
Distribution arch = new ArchDistribution();
Package pack = arch.getPackageTree("bash", 1).get();
Assertions.assertNotEquals(pack.getDeps().size(), 0);
for(Package dep : pack.getDeps()){
Assertions.assertEquals(dep.getDeps().size(), 0);
}
}
@Test
public void testBashIsInCore() throws ExecutionException, InterruptedException {
Distribution arch = new ArchDistribution();
Package pack = arch.getPackageTree("bash", 1).get();
Assertions.assertEquals(pack.getRepo(), "core");
}
@Test
public void testBashDescriptionIsNotEmpty() throws ExecutionException, InterruptedException {
Distribution arch = new ArchDistribution();
Package pack = arch.getPackageTree("bash", 1).get();
Assertions.assertFalse(pack.getDescription().isEmpty());
}
@Test
public void testBashVersionIsNotEmpty() throws ExecutionException, InterruptedException {
Distribution arch = new ArchDistribution();
Package pack = arch.getPackageTree("bash", 1).get();
Assertions.assertFalse(pack.getVersion().isEmpty());
}
}