Class CLIRepositoryTestCase

    • Field Detail

      • db

        protected Repository db
        Test repository, initialized for this test case.
    • Constructor Detail

      • CLIRepositoryTestCase

        public CLIRepositoryTestCase()
    • Method Detail

      • executeUnchecked

        protected String[] executeUnchecked​(String... cmds)
                                     throws Exception
        Executes specified git commands (with arguments)
        Parameters:
        cmds - each string argument must be a valid git command line, e.g. "git branch -h"
        Returns:
        command output
        Throws:
        Exception
      • execute

        protected String[] execute​(String... cmds)
                            throws Exception
        Executes specified git commands (with arguments), throws exception and stops execution on first command which output contains a 'fatal:' error
        Parameters:
        cmds - each string argument must be a valid git command line, e.g. "git branch -h"
        Returns:
        command output
        Throws:
        Exception
      • writeLink

        protected Path writeLink​(String link,
                                 String target)
                          throws Exception
        Parameters:
        link - the path of the symbolic link to create
        target - the target of the symbolic link
        Returns:
        the path to the symbolic link
        Throws:
        Exception
      • executeAndPrint

        protected String[] executeAndPrint​(String... cmds)
                                    throws Exception
        Execute the given commands and print the output to stdout. Use this function instead of the normal execute(String...) when preparing a test case: the command is executed and then its output is printed on stdout, thus making it easier to prepare the correct command and expected output for the test case.
        Parameters:
        cmds - The commands to execute
        Returns:
        the result of the command, see execute(String...)
        Throws:
        Exception
      • executeAndPrintTestCode

        protected String[] executeAndPrintTestCode​(String... cmds)
                                            throws Exception
        Execute the given commands and print test code comparing expected and actual output. Use this function instead of the normal execute(String...) when preparing a test case: the command is executed and test code is generated using the command output as a template of what is expected. The code generated is printed on stdout and can be pasted in the test case function.
        Parameters:
        cmds - The commands to execute
        Returns:
        the result of the command, see execute(String...)
        Throws:
        Exception
      • cmdString

        protected String cmdString​(String... cmds)
      • shellQuote

        protected String shellQuote​(File f)
      • assertStringArrayEquals

        protected void assertStringArrayEquals​(String expected,
                                               String[] actual)
      • assertArrayOfLinesEquals

        protected void assertArrayOfLinesEquals​(String[] expected,
                                                String[] actual)
      • toString

        public static String toString​(String... lines)
      • contains

        public static boolean contains​(List<String> lines,
                                       String str)