Skip to content

Commit

Permalink
Improve test coverage (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Feb 28, 2023
1 parent 0291545 commit 66806f1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ private boolean onlyOnePluginIncluded() {
* @return Update center data
*/
@SuppressFBWarnings(value = "REDOS", justification = "intended behavior")
private UpdateSite.Data scanWAR(File war, String pluginRegExp) {
static UpdateSite.Data scanWAR(File war, String pluginRegExp) {
UpdateSite.Entry core = null;
List<UpdateSite.Plugin> plugins = new ArrayList<>();
try (JarFile jf = new JarFile(war)) {
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/org/jenkins/tools/test/PluginCompatTesterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
import static org.hamcrest.core.Is.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import hudson.model.UpdateSite;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -86,6 +88,24 @@ void smokes(@TempDir File tempDir) throws Exception {
assertEquals(0, failures);
}

@Test
void updateSite() {
UpdateSite.Data data =
PluginCompatTester.scanWAR(
new File("target", "megawar.war").getAbsoluteFile(),
"WEB-INF/(?:optional-)?plugins/([^/.]+)[.][hj]pi");
assertEquals("core", data.core.name);
assertNotNull(data.core.version);
assertEquals("https://foobar", data.core.url);
UpdateSite.Plugin plugin = data.plugins.get("text-finder");
assertNotNull(plugin);
assertEquals("Text Finder", plugin.getDisplayName());
assertEquals("Text Finder", plugin.title);
assertEquals("text-finder", plugin.name);
assertNotNull(plugin.version);
assertNotNull(plugin.url);
}

@Test
void testMatcher() {

Expand Down

0 comments on commit 66806f1

Please sign in to comment.