use of com.google.copybara.testing.DummyOrigin in project copybara by google.
the class TransformWorkTest method setup.
@Before
public void setup() throws IOException {
origin = new DummyOrigin().setAuthor(ORIGINAL_AUTHOR);
destination = new RecordsProcessCallDestination();
OptionsBuilder options = new OptionsBuilder();
console = new TestingConsole();
options.setConsole(console);
options.testingOptions.origin = origin;
options.testingOptions.destination = destination;
// We don't care about force for this test
options.setForce(true);
skylark = new SkylarkTestExecutor(options);
workdir = Files.createTempDirectory("workdir");
}
use of com.google.copybara.testing.DummyOrigin in project copybara by google.
the class WorkflowTest method setup.
@Before
public void setup() throws Exception {
options = new OptionsBuilder();
options.setOutputRootToTmpDir();
authoring = "authoring.overwrite('" + DEFAULT_AUTHOR + "')";
includeReleaseNotes = false;
workdir = Files.createTempDirectory("workdir");
Files.createDirectories(workdir);
origin = new DummyOrigin().setAuthor(ORIGINAL_AUTHOR);
originFiles = "glob(['**'], exclude = ['copy.bara.sky', 'excluded/**'])";
destinationFiles = "glob(['**'])";
destination = new RecordsProcessCallDestination();
transformations = ImmutableList.of("" + " core.replace(\n" + " before = '${linestart}${number}',\n" + " after = '${linestart}" + PREFIX + "${number}',\n" + " regex_groups = {\n" + " 'number' : '[0-9]+',\n" + " 'linestart' : '^',\n" + " },\n" + " multiline = True," + " )");
TestingConsole console = new TestingConsole();
options.setConsole(console);
options.testingOptions.origin = origin;
options.testingOptions.destination = destination;
// Force by default unless we are testing the flag.
options.setForce(true);
skylark = new SkylarkTestExecutor(options);
eventMonitor = new TestingEventMonitor();
options.general.enableEventMonitor("test", eventMonitor);
transformWork = TransformWorks.of(workdir, "example", console);
setRevId = true;
smartPrune = false;
migrateNoopChangesField = false;
extraWorkflowFields = ImmutableList.of();
}
use of com.google.copybara.testing.DummyOrigin in project copybara by google.
the class GitDestinationIntegrateTest method testGerritSemiFakeMerge.
@Test
public void testGerritSemiFakeMerge() throws ValidationException, IOException, RepoException {
Path workTree = Files.createTempDirectory("test");
GitRepository repo = gitUtil.mockRemoteRepo("example.com/gerrit").withWorkTree(workTree);
String label = new GerritIntegrateLabel(repo, options.general, "https://example.com/gerrit", 1020, 1, CHANGE_ID).toString();
assertThat(label).isEqualTo("gerrit https://example.com/gerrit 1020 Patch Set 1 " + CHANGE_ID);
GitRevision firstChange = singleChange(workTree, repo, "ignore_me", "Feature1 change");
GitRevision secondChange = singleChange(workTree, repo, "ignore_me2", "Feature2 change");
GitTestUtil.createFakeGerritNodeDbMeta(repo, 1020, CHANGE_ID);
repo.simpleCommand("update-ref", "refs/changes/20/1020/1", firstChange.getSha1());
repo.simpleCommand("update-ref", "refs/changes/20/1020/2", secondChange.getSha1());
GitDestination destination = destinationWithDefaultIntegrates();
GitLogEntry previous = createBaseDestinationChange(destination);
migrateOriginChange(destination, "Test change\n" + "\n" + GitModule.DEFAULT_INTEGRATE_LABEL + "=" + label + "\n", "some content");
// Make sure commit adds new text
String showResult = git("--git-dir", repoGitDir.toString(), "show", primaryBranch);
assertThat(showResult).contains("some content");
GitTesting.assertThatCheckout(repo(), primaryBranch).containsFile("test.txt", "some content").containsFile("ignore_me", "").containsNoMoreFiles();
GitLogEntry merge = getLastMigratedChange(primaryBranch);
assertThat(merge.getBody()).isEqualTo("Merge Gerrit change 1020 Patch Set 1\n" + "\n" + "DummyOrigin-RevId: test\n" + "Change-Id: " + CHANGE_ID + "\n");
assertThat(Lists.transform(merge.getParents(), GitRevision::getSha1)).isEqualTo(Lists.newArrayList(previous.getCommit().getSha1(), firstChange.getSha1()));
assertThat(console.getMessages().stream().filter(e -> e.getType() == MessageType.WARNING).findAny().get().getText()).contains("Change 1020 has more patch sets after Patch Set 1." + " Latest is Patch Set 2. Not all changes might be migrated");
}
use of com.google.copybara.testing.DummyOrigin in project copybara by google.
the class GitDestinationReaderTest method setup.
@Before
public void setup() throws Exception {
destinationPath = Files.createTempDirectory("destination");
gitDir = Files.createTempDirectory("gitDir");
console = new TestingConsole();
options = new OptionsBuilder().setConsole(console);
options.setHomeDir(Files.createTempDirectory("home").toString());
origin = new DummyOrigin();
options.testingOptions.origin = origin;
repo = GitRepository.newBareRepo(destinationPath, getGitEnv(), /*verbose=*/
true, DEFAULT_TIMEOUT, /*noVerify=*/
false).withWorkTree(gitDir).init();
primaryBranch = repo.getPrimaryBranch();
options.gitDestination.committerEmail = "commiter@email";
options.gitDestination.committerName = "Bara Kopi";
workDir = Files.createTempDirectory("workdir");
options.setWorkdirToRealTempDir(workDir.toString());
skylark = new SkylarkTestExecutor(options);
origin.singleFileChange(1580341755, "first", "foo/origin.txt", "AAAA").singleFileChange(1580341795, "second", "foo/origin.txt", "BBBB");
}
use of com.google.copybara.testing.DummyOrigin in project copybara by google.
the class MetadataModuleTest method setup.
@Before
public void setup() throws Exception {
options = new OptionsBuilder();
authoring = "authoring.overwrite('" + DEFAULT_AUTHOR + "')";
workdir = Files.createTempDirectory("workdir");
Files.createDirectories(workdir);
origin = new DummyOrigin().setAuthor(ORIGINAL_AUTHOR);
destination = new RecordsProcessCallDestination();
options.setConsole(new TestingConsole());
options.testingOptions.origin = origin;
options.testingOptions.destination = destination;
skylark = new SkylarkTestExecutor(options);
origin.addSimpleChange(0, "first commit\n\nExtended text").setAuthor(FOO_BAR).addSimpleChange(1, "second commit\n\nExtended text").setAuthor(FOO_BAZ).addSimpleChange(2, "third commit\n\nExtended text");
options.setLastRevision("0");
// We don't care about already migrated code
options.setForce(true);
testingConsole = new TestingConsole();
options.setConsole(testingConsole);
}
Aggregations