Skip to content

Commit

Permalink
Merge pull request #342 from timja/fix-main-build
Browse files Browse the repository at this point in the history
Remove broken powermock test (fix mainline)
  • Loading branch information
imonteroperez authored Jan 28, 2022
2 parents 460dafb + e6775f1 commit 8e47233
Showing 1 changed file with 0 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.powermock.api.mockito.PowerMockito.mock;
import static org.powermock.api.mockito.PowerMockito.spy;
import static org.powermock.api.mockito.PowerMockito.when;

import hudson.model.UpdateSite;
import java.io.File;
Expand All @@ -17,9 +14,6 @@
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.maven.scm.command.checkout.CheckOutScmResult;
import org.apache.maven.scm.manager.ScmManager;
import org.apache.maven.scm.repository.ScmRepository;
import org.jenkins.tools.test.hook.NonStandardTagHook;
import org.jenkins.tools.test.model.MavenCoordinates;
import org.jenkins.tools.test.model.PluginCompatTesterConfig;
Expand All @@ -28,13 +22,8 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.core.io.ClassPathResource;

@RunWith(PowerMockRunner.class)
public class NonStandardTagHookTest {

@Rule
Expand Down Expand Up @@ -86,41 +75,6 @@ public void testCheckMethodWithMinimumVersion() {
}
}

@Test
@PrepareForTest({SCMManagerFactory.class,NonStandardTagHook.class})
public void testActionGeneratesProperInfo() throws Exception {
spy(SCMManagerFactory.class);
SCMManagerFactory mockFactory = mock(SCMManagerFactory.class);
ScmManager mockManager = mock(ScmManager.class);
CheckOutScmResult mockResult = mock(CheckOutScmResult.class);
when(mockResult.isSuccess()).thenReturn(Boolean.TRUE);
when(mockManager.checkOut(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(mockResult);
when(mockManager.makeScmRepository(Mockito.anyString())).thenReturn(mock(ScmRepository.class));
when(mockFactory.createScmManager()).thenReturn(mockManager);
when(SCMManagerFactory.getInstance()).thenReturn(mockFactory);


Map<String, Object> info = new HashMap<>();
PomData data = new PomData("artifactID", "hpi", null, null, null, null);
info.put("pomData", data);
JSONObject pluginData = new JSONObject();
pluginData.put("name","artifactId");
pluginData.put("version","9.9.99");
pluginData.put("url", "example.com");
pluginData.put("dependencies", new JSONArray());
UpdateSite.Plugin plugin = new UpdateSite("fake", "fake").new Plugin("NO Source",pluginData);
info.put("plugin", plugin);
PluginCompatTesterConfig config = new PluginCompatTesterConfig(new File(testFolder.getRoot(), "noexists"), null, null);
info.put("config", config);

NonStandardTagHook hook = new NonStandardTagHook();
Map<String, Object> returnedConfig = hook.action(info);
assertEquals("Checkout dir is not the expected", new File(testFolder.getRoot(), "noexists/artifactID"), returnedConfig.get("checkoutDir"));
assertEquals("Checkout dir is not the same as plugin dir", returnedConfig.get("checkoutDir"), returnedConfig.get("pluginDir"));
assertEquals("RunCheckout should be false", Boolean.FALSE, returnedConfig.get("runCheckout"));

}

@Test
public void testActuallyPerformsTheCheckoutWithVersionGreaterThanMinimum() {

Expand Down

0 comments on commit 8e47233

Please sign in to comment.