Search in sources :

Example 36 with SkylarkTestExecutor

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

the class PatchTransformationTest method setup.

@Before
public void setup() throws IOException {
    checkoutDir = Files.createTempDirectory("workdir");
    Files.createDirectories(checkoutDir);
    console = new TestingConsole();
    options = new OptionsBuilder().setConsole(console);
    patchingOptions = options.build().get(PatchingOptions.class);
    skylark = new SkylarkTestExecutor(options);
    ImmutableMap<String, byte[]> configFiles = ImmutableMap.of("diff.patch", (DIFF).getBytes(UTF_8), "series", ("diff.patch\n").getBytes(UTF_8));
    patchFile = new MapConfigFile(configFiles, "diff.patch");
    seriesFile = new MapConfigFile(configFiles, "series");
    options.setEnvironment(GitTestUtil.getGitEnv().getEnvironment());
    // In preparation to switch to the new default. PatchingOptionsTest has more coverage on this.
    options.patch.useGitApply = false;
    options.patch.skipVersionCheck = false;
}
Also used : TestingConsole(com.google.copybara.util.console.testing.TestingConsole) MapConfigFile(com.google.copybara.config.MapConfigFile) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 37 with SkylarkTestExecutor

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

the class RevisionMigratorTest method setUp.

@Before
public void setUp() throws Exception {
    FileSystem fs = Jimfs.newFileSystem();
    checkoutDir = fs.getPath("/test-checkoutDir");
    origin = new DummyOrigin();
    destinationReader = new MockReader();
    location = Location.fromFileLineColumn("file", 1, 2);
    referenceMigrator = ReferenceMigrator.create("http://internalReviews.com/${reference}", "http://externalreviews.com/view?${reference}", Pattern.compile("[0-9]+"), Pattern.compile("[0-9a-f]+"), ImmutableList.of(), location);
    OptionsBuilder options = new OptionsBuilder();
    console = new TestingConsole();
    options.setConsole(console);
    skylark = new SkylarkTestExecutor(options);
}
Also used : DummyOrigin(com.google.copybara.testing.DummyOrigin) TestingConsole(com.google.copybara.util.console.testing.TestingConsole) FileSystem(java.nio.file.FileSystem) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) Before(org.junit.Before)

Example 38 with SkylarkTestExecutor

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

the class GlobTest method setup.

@Before
public void setup() throws IOException, RepoException {
    workdir = Files.createTempDirectory("workdir");
    OptionsBuilder options = new OptionsBuilder().setWorkdirToRealTempDir().setConsole(new TestingConsole());
    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 39 with SkylarkTestExecutor

use of com.google.copybara.testing.SkylarkTestExecutor 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");
    localHub = Files.createTempDirectory("localHub");
    git("init", "--bare", repoGitDir.toString());
    console = new TestingConsole();
    options = new OptionsBuilder().setConsole(console).setOutputRootToTmpDir();
    options.git = new TestGitOptions(localHub, () -> this.options.general, new Validator() {

        @Override
        public void validateFetch(String url, boolean prune, boolean force, Iterable<String> refspecs) {
            for (String refspec : refspecs) {
                // WARNING! This check is important. While using short names like
                // 'master' in git fetch works for local git invocations, other
                // implementations of GitRepository might have problems if we don't
                // pass the whole reference.
                assertThat(refspec).startsWith("refs/");
                assertThat(refspec).contains(":refs/");
            }
        }
    });
    options.github = new GithubOptions(() -> options.general, options.git) {

        @Override
        public GithubApi getApi(String project) throws RepoException {
            assertThat(project).isEqualTo(expectedProject);
            return super.getApi(project);
        }

        @Override
        protected HttpTransport getHttpTransport() {
            return gitApiMockHttpTransport;
        }
    };
    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, GitModule.class);
    skylarkParser = new SkylarkParser(ImmutableSet.of(Core.class, Authoring.Module.class, FolderModule.class, GitModule.class));
}
Also used : Path(java.nio.file.Path) SkylarkParser(com.google.copybara.config.SkylarkParser) TestGitOptions(com.google.copybara.testing.git.GitTestUtil.TestGitOptions) GithubApi(com.google.copybara.git.github.api.GithubApi) RepoException(com.google.copybara.exception.RepoException) OptionsBuilder(com.google.copybara.testing.OptionsBuilder) SkylarkTestExecutor(com.google.copybara.testing.SkylarkTestExecutor) HttpTransport(com.google.api.client.http.HttpTransport) GitApiMockHttpTransport(com.google.copybara.testing.OptionsBuilder.GitApiMockHttpTransport) Authoring(com.google.copybara.authoring.Authoring) TestingConsole(com.google.copybara.util.console.testing.TestingConsole) Validator(com.google.copybara.testing.git.GitTestUtil.Validator) Before(org.junit.Before)

Example 40 with SkylarkTestExecutor

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

the class CoreReverseTest method setup.

@Before
public void setup() {
    OptionsBuilder options = new OptionsBuilder();
    skylark = new SkylarkTestExecutor(options).withStaticModules(ImmutableSet.of(Mock.class));
    console = new TestingConsole();
    options.setConsole(console);
}
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)

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