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.

DescriptionTest.java 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (C) 2016, Google Inc. 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.internal.storage.file;
  11. import static org.junit.Assert.assertEquals;
  12. import static org.junit.Assert.assertNull;
  13. import java.io.File;
  14. import java.io.IOException;
  15. import org.eclipse.jgit.junit.LocalDiskRepositoryTestCase;
  16. import org.eclipse.jgit.lib.Repository;
  17. import org.junit.Test;
  18. /** Test managing the gitweb description file. */
  19. public class DescriptionTest extends LocalDiskRepositoryTestCase {
  20. private static final String UNCONFIGURED = "Unnamed repository; edit this file to name it for gitweb.";
  21. @Test
  22. public void description() throws IOException {
  23. Repository git = createBareRepository();
  24. File path = new File(git.getDirectory(), "description");
  25. assertNull("description", git.getGitwebDescription());
  26. String desc = "a test repo\nfor jgit";
  27. git.setGitwebDescription(desc);
  28. assertEquals(desc + '\n', read(path));
  29. assertEquals(desc, git.getGitwebDescription());
  30. git.setGitwebDescription(null);
  31. assertEquals("", read(path));
  32. desc = "foo";
  33. git.setGitwebDescription(desc);
  34. assertEquals(desc + '\n', read(path));
  35. assertEquals(desc, git.getGitwebDescription());
  36. git.setGitwebDescription("");
  37. assertEquals("", read(path));
  38. git.setGitwebDescription(UNCONFIGURED);
  39. assertEquals(UNCONFIGURED + '\n', read(path));
  40. assertNull("description", git.getGitwebDescription());
  41. }
  42. }