You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

InitTest.java 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (C) 2016, Rüdiger Herrmann <ruediger.herrmann@gmx.de> and others
  3. *
  4. * This program and the accompanying materials are made available under the
  5. * terms of the Eclipse Distribution License v. 1.0 which is available at
  6. * https://www.eclipse.org/org/documents/edl-v10.php.
  7. *
  8. * SPDX-License-Identifier: BSD-3-Clause
  9. */
  10. package org.eclipse.jgit.pgm;
  11. import static org.junit.Assert.assertArrayEquals;
  12. import java.io.File;
  13. import org.eclipse.jgit.lib.CLIRepositoryTestCase;
  14. import org.eclipse.jgit.lib.Constants;
  15. import org.junit.Rule;
  16. import org.junit.Test;
  17. import org.junit.rules.TemporaryFolder;
  18. public class InitTest extends CLIRepositoryTestCase {
  19. @Rule
  20. public final TemporaryFolder tempFolder = new TemporaryFolder();
  21. @Test
  22. public void testInitBare() throws Exception {
  23. File directory = tempFolder.getRoot();
  24. String[] result = execute(
  25. "git init '" + directory.getCanonicalPath() + "' --bare");
  26. String[] expecteds = new String[] {
  27. "Initialized empty Git repository in "
  28. + directory.getCanonicalPath(),
  29. "" };
  30. assertArrayEquals(expecteds, result);
  31. }
  32. @Test
  33. public void testInitDirectory() throws Exception {
  34. File workDirectory = tempFolder.getRoot();
  35. File gitDirectory = new File(workDirectory, Constants.DOT_GIT);
  36. String[] result = execute(
  37. "git init '" + workDirectory.getCanonicalPath() + "'");
  38. String[] expecteds = new String[] {
  39. "Initialized empty Git repository in "
  40. + gitDirectory.getCanonicalPath(),
  41. "" };
  42. assertArrayEquals(expecteds, result);
  43. }
  44. }