From 3b558c2cafc9ed018e32556099091a2b415384d9 Mon Sep 17 00:00:00 2001 From: Thomas Rubini <74205383+ThomasRubini@users.noreply.github.com> Date: Tue, 13 Dec 2022 09:07:32 +0100 Subject: [PATCH] add tests for Arch --- src/test/java/fr/packageviewer/ArchTest.java | 60 ++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/test/java/fr/packageviewer/ArchTest.java diff --git a/src/test/java/fr/packageviewer/ArchTest.java b/src/test/java/fr/packageviewer/ArchTest.java new file mode 100644 index 0000000..4ee98ee --- /dev/null +++ b/src/test/java/fr/packageviewer/ArchTest.java @@ -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()); + } +}