use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitHubTriggerTest 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);
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitOriginSubmodulesTest method setup.
@Before
public void setup() throws Exception {
OptionsBuilder options = new OptionsBuilder().setConsole(new TestingConsole()).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.setHomeDir(userHomeForTest.toString());
checkoutDir = Files.createTempDirectory("checkout");
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitOriginTest method testGitUrlOverwrite.
/**
* Check that we can overwrite the git url using the CLI option and that we show a message
*/
@Test
public void testGitUrlOverwrite() throws Exception {
createTestRepo(Files.createTempDirectory("cliremote"));
git("init");
writeFile(remote, "cli_remote.txt", "some change");
repo.add().files("cli_remote.txt").run();
git("commit", "-m", "a change from somewhere");
TestingConsole testConsole = new TestingConsole();
options.setConsole(testConsole);
origin = origin();
String newUrl = "file://" + remote.toFile().getAbsolutePath();
Reader<GitRevision> reader = newReader();
Change<GitRevision> cliHead = reader.change(origin.resolve(newUrl));
reader.checkout(cliHead.getRevision(), checkoutDir);
assertThat(cliHead.firstLineMessage()).isEqualTo("a change from somewhere");
assertThatPath(checkoutDir).containsFile("cli_remote.txt", "some change").containsNoMoreFiles();
testConsole.assertThat().onceInLog(MessageType.WARNING, "Git origin URL overwritten in the command line as " + newUrl);
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitOriginTest 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());
createTestRepo(Files.createTempDirectory("remote"));
checkoutDir = Files.createTempDirectory("checkout");
url = "file://" + remote.toFile().getAbsolutePath();
ref = "other";
moreOriginArgs = "";
origin = origin();
writeFile(remote, "test.txt", "some content");
defaultBranch = repo.simpleCommand("symbolic-ref", "--short", "HEAD").getStdout().trim();
repo.add().files("test.txt").run();
git("commit", "-m", "first file", "--date", COMMIT_TIME);
firstCommitRef = repo.parseRef("HEAD");
originFiles = Glob.ALL_FILES;
}
use of com.google.copybara.util.console.testing.TestingConsole in project copybara by google.
the class GitHubApiTransportImplTest method testPasswordHeaderSet.
@Test
public void testPasswordHeaderSet() throws Exception {
Map<String, List<String>> headers = new HashMap<>();
httpTransport = new MockHttpTransport() {
@Override
public LowLevelHttpRequest buildRequest(String method, String url) {
return new MockLowLevelHttpRequest() {
@Override
public LowLevelHttpResponse execute() throws IOException {
headers.putAll(this.getHeaders());
MockLowLevelHttpResponse response = new MockLowLevelHttpResponse();
response.setContent("foo");
return response;
}
};
}
};
transport = new GitHubApiTransportImpl(repo, httpTransport, "store", new TestingConsole());
transport.get("foo/bar", String.class);
assertThat(headers).containsEntry("authorization", ImmutableList.of("Basic dXNlcjpTRUNSRVQ="));
}
Aggregations