Search in sources :

Example 16 with SkylarkTestExecutor

use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.

the class BuildozerCreateTest method setup.

@Before
public void setup() throws IOException {
    console = new TestingConsole();
    options = new OptionsBuilder();
    options.setConsole(console);
    BuildozerTesting.enable(options);
    checkoutDir = Files.createTempDirectory("BuildozerCreateTest");
    skylark = new SkylarkTestExecutor(options);
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 17 with SkylarkTestExecutor

use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.

the class FolderOriginTest method setup.

@Before
public void setup() throws IOException, RepoException {
    workdir = Files.createTempDirectory("workdir");
    options = new OptionsBuilder().setWorkdirToRealTempDir().setHomeDir(StandardSystemProperty.USER_HOME.value());
    skylark = new SkylarkTestExecutor(options);
}
Also used : OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 18 with SkylarkTestExecutor

use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.

the class GerritOriginTest method setup.

@Before
public void setup() throws Exception {
    options = new OptionsBuilder();
    console = new TestingConsole();
    options = new OptionsBuilder().setConsole(console).setOutputRootToTmpDir();
    skylark = new SkylarkTestExecutor(options);
    // Pass custom HOME directory so that we run an hermetic test and we
    // can add custom configuration to $HOME/.gitconfig.
    Path userHomeForTest = Files.createTempDirectory("home");
    options.setEnvironment(GitTestUtil.getGitEnv().getEnvironment());
    options.setHomeDir(userHomeForTest.toString());
    gitUtil = new GitTestUtil(options);
    gitUtil.mockRemoteGitRepos();
    createTestRepo();
    String url = "https://" + REPO_URL;
    origin = skylark.eval("result", String.format("result = " + "git.gerrit_origin(" + "    url = '%s'," + ")", url));
    Files.write(remote.resolve("base.txt"), new byte[0]);
    repo.add().files("base.txt").run();
    git("commit", "-m", "baseline", "--date", commitTime);
    baseline = repo.parseRef("HEAD");
    Files.write(remote.resolve("test.txt"), "some content".getBytes(UTF_8));
    repo.add().files("test.txt").run();
    git("commit", "-m", "first change", "--date", commitTime);
    firstRevision = new GitRevision(repo, repo.parseRef("HEAD"), GerritChange.gerritPatchSetAsReviewReference(1), "12345", ImmutableListMultimap.<String, String>builder().put(GerritChange.GERRIT_CHANGE_NUMBER_LABEL, "12345").put(GerritChange.GERRIT_CHANGE_ID_LABEL, CHANGE_ID).put(GerritChange.GERRIT_COMPLETE_CHANGE_ID_LABEL, "my_branch-12345").put(GerritChange.GERRIT_CHANGE_BRANCH, "my_branch").put(GERRIT_OWNER_EMAIL_LABEL, "the_owner@example.com").put("GERRIT_REVIEWER_EMAIL", "foo@example.com").put("GERRIT_REVIEWER_EMAIL", "bar@example.com").put("GERRIT_CC_EMAIL", "baz@example.com").put(GerritChange.GERRIT_CHANGE_DESCRIPTION_LABEL, CHANGE_DESCRIPTION).put(DEFAULT_INTEGRATE_LABEL, "gerrit " + url + " 12345 Patch Set 1 " + CHANGE_ID).put(GitRepository.GIT_DESCRIBE_REQUESTED_VERSION, repo.parseRef("HEAD").substring(0, 7)).put(GitRepository.GIT_DESCRIBE_FIRST_PARENT, repo.parseRef("HEAD").substring(0, 7)).put(GitRepository.GIT_DESCRIBE_ABBREV, "").build(), url);
    git("update-ref", "refs/changes/45/12345/1", firstRevision.getSha1());
    git("commit", "-m", "second change", "--date", commitTime, "--amend");
    Files.write(remote.resolve("foo.md"), "some content".getBytes(UTF_8));
    repo.add().files("foo.md").run();
    secondRevision = new GitRevision(repo, repo.parseRef("HEAD"), GerritChange.gerritPatchSetAsReviewReference(2), "12345", ImmutableListMultimap.<String, String>builder().put(GerritChange.GERRIT_CHANGE_NUMBER_LABEL, "12345").put(GerritChange.GERRIT_CHANGE_ID_LABEL, CHANGE_ID).put(GerritChange.GERRIT_COMPLETE_CHANGE_ID_LABEL, "my_branch-12345").put(GerritChange.GERRIT_CHANGE_BRANCH, "my_branch").put(GERRIT_OWNER_EMAIL_LABEL, "the_owner@example.com").put("GERRIT_REVIEWER_EMAIL", "foo@example.com").put("GERRIT_REVIEWER_EMAIL", "bar@example.com").put("GERRIT_CC_EMAIL", "baz@example.com").put(GerritChange.GERRIT_CHANGE_DESCRIPTION_LABEL, CHANGE_DESCRIPTION).put(GitRepository.GIT_DESCRIBE_REQUESTED_VERSION, repo.parseRef("HEAD").substring(0, 7)).put(GitRepository.GIT_DESCRIBE_FIRST_PARENT, repo.parseRef("HEAD").substring(0, 7)).put(GitRepository.GIT_DESCRIBE_ABBREV, "").put(DEFAULT_INTEGRATE_LABEL, "gerrit " + url + " 12345 Patch Set 2 " + CHANGE_ID).build(), url);
    git("update-ref", "refs/changes/45/12345/2", secondRevision.getSha1());
    git("commit", "-m", "third change", "--date", commitTime, "--amend");
    thirdRevision = new GitRevision(repo, repo.parseRef("HEAD"), GerritChange.gerritPatchSetAsReviewReference(3), "12345", ImmutableListMultimap.<String, String>builder().put(GerritChange.GERRIT_CHANGE_NUMBER_LABEL, "12345").put(GerritChange.GERRIT_COMPLETE_CHANGE_ID_LABEL, "my_branch-12345").put(GerritChange.GERRIT_CHANGE_BRANCH, "my_branch").put(GERRIT_OWNER_EMAIL_LABEL, "the_owner@example.com").put("GERRIT_REVIEWER_EMAIL", "foo@example.com").put("GERRIT_REVIEWER_EMAIL", "bar@example.com").put("GERRIT_CC_EMAIL", "baz@example.com").put(GerritChange.GERRIT_CHANGE_ID_LABEL, CHANGE_ID).put(GerritChange.GERRIT_CHANGE_DESCRIPTION_LABEL, CHANGE_DESCRIPTION).put(GitRepository.GIT_DESCRIBE_REQUESTED_VERSION, repo.parseRef("HEAD").substring(0, 7)).put(GitRepository.GIT_DESCRIBE_FIRST_PARENT, repo.parseRef("HEAD").substring(0, 7)).put(GitRepository.GIT_DESCRIBE_ABBREV, "").put(DEFAULT_INTEGRATE_LABEL, "gerrit " + url + " 12345 Patch Set 3 " + CHANGE_ID).build(), url);
    git("update-ref", "refs/changes/45/12345/3", thirdRevision.getSha1());
    GitTestUtil.createFakeGerritNodeDbMeta(repo, 12345, CHANGE_ID);
}
Also used : Path(java.nio.file.Path) TestingConsole(com.google.copybara.util.console.testing.TestingConsole) GitTestUtil(com.google.copybara.testing.git.GitTestUtil) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 19 with SkylarkTestExecutor

use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.

the class GerritTriggerTest method setup.

@Before
public void setup() throws Exception {
    TestingConsole console = new TestingConsole();
    OptionsBuilder options = new OptionsBuilder();
    options.setConsole(console).setOutputRootToTmpDir();
    options.testingOptions.checker = new DummyChecker(ImmutableSet.of("badword"));
    skylarkTestExecutor = new SkylarkTestExecutor(options);
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) DummyChecker(com.google.copybara.testing.DummyChecker) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 20 with SkylarkTestExecutor

use of com.google.copybara.testing.SkylarkTestExecutor in project copybara by google.

the class GitDestinationIntegrateTest method setup.

@Before
public void setup() throws Exception {
    repoGitDir = Files.createTempDirectory("GitDestinationTest-repoGitDir");
    workdir = Files.createTempDirectory("workdir");
    git("init", "--bare", repoGitDir.toString());
    console = new TestingConsole();
    options = new OptionsBuilder().setConsole(console).setOutputRootToTmpDir();
    gitUtil = new GitTestUtil(options);
    gitUtil.mockRemoteGitRepos();
    options.gitDestination = new GitDestinationOptions(options.general, options.git);
    options.gitDestination.committerEmail = "commiter@email";
    options.gitDestination.committerName = "Bara Kopi";
    destinationFiles = Glob.createGlob(ImmutableList.of("**"), ImmutableList.of("ignore*"));
    options.setForce(true);
    url = "file://" + repoGitDir;
    skylark = new SkylarkTestExecutor(options);
    primaryBranch = repo().getPrimaryBranch();
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) GitTestUtil(com.google.copybara.testing.git.GitTestUtil) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Aggregations

SkylarkTestExecutor (com.google.copybara.testing.SkylarkTestExecutor)70 OptionsBuilder (com.google.copybara.testing.OptionsBuilder)58 Before (org.junit.Before)58 TestingConsole (com.google.copybara.util.console.testing.TestingConsole)54 Path (java.nio.file.Path)17 Test (org.junit.Test)14 GitTestUtil (com.google.copybara.testing.git.GitTestUtil)9 DummyOrigin (com.google.copybara.testing.DummyOrigin)8 ValidationException (com.google.copybara.exception.ValidationException)7 FileSystem (java.nio.file.FileSystem)7 DummyChecker (com.google.copybara.testing.DummyChecker)6 RecordsProcessCallDestination (com.google.copybara.testing.RecordsProcessCallDestination)6 MapConfigFile (com.google.copybara.config.MapConfigFile)4 RepoException (com.google.copybara.exception.RepoException)4 Console (com.google.copybara.util.console.Console)4 IOException (java.io.IOException)4 LowLevelHttpRequest (com.google.api.client.http.LowLevelHttpRequest)3 ImmutableList (com.google.common.collect.ImmutableList)3 Truth.assertThat (com.google.common.truth.Truth.assertThat)3 DummyRevision (com.google.copybara.testing.DummyRevision)3