Skip to content
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

[GSoC] Addition of unit test for WipeWorkspace extension behavior in GitSCM #852

Merged
merged 3 commits into from
Mar 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,52 @@
package hudson.plugins.git.extensions.impl;

import hudson.EnvVars;
import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.model.Result;
import hudson.plugins.git.GitSCM;
import hudson.plugins.git.TestGitRepo;
import hudson.plugins.git.extensions.GitSCMExtension;
import hudson.plugins.git.extensions.GitSCMExtensionTest;
import nl.jqno.equalsverifier.EqualsVerifier;
import org.jenkinsci.plugins.gitclient.Git;
import org.jenkinsci.plugins.gitclient.GitClient;
import org.junit.Test;

public class WipeWorkspaceTest {
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class WipeWorkspaceTest extends GitSCMExtensionTest {

TestGitRepo repo;
GitClient git;

@Override
public void before() throws Exception {
repo = new TestGitRepo("repo", tmp.newFolder(), listener);
git = Git.with(listener, new EnvVars()).in(repo.gitDir).getClient();
}

@Override
protected GitSCMExtension getExtension() {
return new WipeWorkspace();
}

/**
* Test to confirm the behavior of forcing re-clone before checkout by cleaning the workspace first.
**/
@Test
public void testWipeWorkspace() throws Exception {
FreeStyleProject projectWithMaster = setupBasicProject(repo);
WipeWorkspace wipeWorkspaceExtension = new WipeWorkspace();
((GitSCM)projectWithMaster.getScm()).getExtensions().add(wipeWorkspaceExtension);
MarkEWaite marked this conversation as resolved.
Show resolved Hide resolved

git.commit("First commit");
FreeStyleBuild build = build(projectWithMaster, Result.SUCCESS);

String buildLog = build.getLog();
assertThat("Workspace not cleaned before checkout",true, is(buildLog.contains("Wiping out workspace first.")));
}

@Test
MarkEWaite marked this conversation as resolved.
Show resolved Hide resolved
public void equalsContract() {
Expand Down