use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitDestinationTest method setup.
@Before
public void setup() throws Exception {
repoGitDir = Files.createTempDirectory("GitDestinationTest-repoGitDir");
workdir = Files.createTempDirectory("workdir");
console = new TestingConsole();
options = getOptionsBuilder(console);
git("init", "--bare", repoGitDir.toString());
options.gitDestination.committerEmail = "commiter@email";
options.gitDestination.committerName = "Bara Kopi";
destinationFiles = Glob.createGlob(ImmutableList.of("**"));
partialClone = "False";
checker = "None";
url = "file://" + repoGitDir;
skylark = new SkylarkTestExecutor(options);
force = false;
tagName = "test_v1";
tagMsg = "foo_tag";
primaryBranch = repo().getPrimaryBranch();
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitDestinationTest method processUserConfirms.
@Test
public void processUserConfirms() throws Exception {
console = new TestingConsole().respondYes();
fetch = primaryBranch;
push = primaryBranch;
Files.write(workdir.resolve("test.txt"), "some content".getBytes(UTF_8));
processWithBaselineAndConfirmation(firstCommitWriter(), destinationFiles, new DummyRevision("origin_ref"), /*baseline=*/
null, /*askForConfirmation=*/
true);
String change = git("--git-dir", repoGitDir.toString(), "show", "HEAD");
// Validate that we really have pushed the commit.
assertThat(change).contains("test summary");
console.assertThat().matchesNext(MessageType.PROGRESS, "Git Destination: Fetching: file:.* refs/heads/.*").matchesNext(MessageType.WARNING, "Git Destination: 'refs/heads/.*' doesn't exist in 'file://.*").matchesNext(MessageType.PROGRESS, "Git Destination: Checking out .*").matchesNext(MessageType.PROGRESS, "Git Destination: Adding all files").matchesNext(MessageType.PROGRESS, "Git Destination: Excluding files").matchesNext(MessageType.PROGRESS, "Git Destination: Creating a local commit").matchesNext(MessageType.VERBOSE, "Integrates for.*").matchesNext(MessageType.INFO, "(?m)(\n|.)*test summary(\n|.)+" + "diff --git a/test.txt b/test.txt\n" + "new file mode 100644\n" + "index 0000000\\.\\.f0eec86\n" + "--- /dev/null\n" + "\\+\\+\\+ b/test.txt\n" + "@@ -0,0 \\+1 @@\n" + "\\+some content\n" + "\\\\ No newline at end of file\n").matchesNext(MessageType.WARNING, "Proceed with push to.*[?]").matchesNext(MessageType.PROGRESS, "Git Destination: Pushing to .*").containsNoMoreMessages();
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitHubDestinationTest method setup.
@Before
public void setup() throws Exception {
console = new TestingConsole();
options = new OptionsBuilder().setConsole(console).setOutputRootToTmpDir();
options.testingOptions.checker = new DummyChecker(ImmutableSet.of("bad_word"));
workdir = Files.createTempDirectory("workdir");
destinationFiles = Glob.createGlob(ImmutableList.of("**"));
gitUtil = new GitTestUtil(options);
gitUtil.mockRemoteGitRepos(new CompleteRefValidator());
remote = gitUtil.mockRemoteRepo("github.com/foo");
primaryBranch = remote.getPrimaryBranch();
Path credentialsFile = Files.createTempFile("credentials", "test");
Files.write(credentialsFile, "https://user:SECRET@github.com".getBytes(UTF_8));
options.git.credentialHelperStorePath = credentialsFile.toString();
options.gitDestination = new GitDestinationOptions(options.general, options.git);
options.gitDestination.committerEmail = "commiter@email";
options.gitDestination.committerName = "Bara Kopi";
url = "https://github.com/foo";
force = false;
fetch = primaryBranch;
push = primaryBranch;
skylark = new SkylarkTestExecutor(options);
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitHubPrOriginTest method setup.
@Before
public void setup() throws Exception {
repoGitDir = Files.createTempDirectory("GitHubPrDestinationTest-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(new CompleteRefValidator());
Path credentialsFile = Files.createTempFile("credentials", "test");
Files.write(credentialsFile, "https://user:SECRET@github.com".getBytes(UTF_8));
options.git.credentialHelperStorePath = credentialsFile.toString();
skylark = new SkylarkTestExecutor(options);
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitMirrorTest method setup.
@Before
public void setup() throws Exception {
workdir = Files.createTempDirectory("workdir");
console = new TestingConsole();
options = new OptionsBuilder().setEnvironment(GitTestUtil.getGitEnv().getEnvironment()).setOutputRootToTmpDir().setWorkdirToRealTempDir().setConsole(console);
originRepo = newBareRepo(Files.createTempDirectory("gitdir"), getGitEnv(), /*verbose=*/
true, DEFAULT_TIMEOUT, /*noVerify=*/
false).withWorkTree(Files.createTempDirectory("worktree"));
originRepo.init();
destRepo = bareRepo(Files.createTempDirectory("destinationFolder"));
destRepo.init();
skylark = new SkylarkTestExecutor(options);
Files.write(originRepo.getWorkTree().resolve("test.txt"), "some content".getBytes(UTF_8));
originRepo.add().files("test.txt").run();
originRepo.simpleCommand("commit", "-m", "first file");
originRepo.simpleCommand("branch", "other");
primaryBranch = originRepo.getPrimaryBranch();
}
Aggregations