package pro.cucumber;

import org.junit.Before;
import org.junit.Test;
import pro.cucumber.gitcli.GitCliRevisionProvider;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.regex.Pattern;

import static org.junit.Assert.assertTrue;

public abstract class RevisionProviderContract {
    private Path rootPath;

    @Before
    public void createScm() throws IOException {
        rootPath = Files.createTempDirectory("GitWC");
        Path subfolder = rootPath.resolve("subfolder");
        Files.createDirectory(subfolder);
        Files.createFile(subfolder.resolve("file"));
        Exec.cmd("git init", rootPath);
        Exec.cmd("git add -A", rootPath);
        Exec.cmd("git commit -am \"files\"", rootPath);
    }

    @Test
    public void findsRev() {
        String sha1Pattern = "^[a-f0-9]{40}$";
        RevisionProvider revisionProvider = makeRevisionProvider(rootPath);
        String rev = revisionProvider.getRev();
        assertTrue("Expected a sha1, got: "+rev, Pattern.matches(sha1Pattern, rev));
    }

    protected abstract RevisionProvider makeRevisionProvider(Path rootPath);

}
@@ -67,59 +67,8 @@
 est;
-%0Aimport pro.cucumber.gitcli.GitCliRevisionProvider;
 %0A%0Aim
@@ -169,23 +169,119 @@
 til.
-regex.Pattern;%0A
+ArrayList;%0Aimport java.util.List;%0Aimport java.util.regex.Pattern;%0A%0Aimport static org.junit.Assert.assertEquals;
 %0Aimp
@@ -799,24 +799,155 @@
  rootPath);%0A
+        List%3CString%3E status = Exec.cmd(%22git status --porcelain%22, rootPath);%0A        assertEquals(new ArrayList%3CString%3E(), status);%0A
     %7D%0A%0A    @
@@ -1198,9 +1198,11 @@
 t: %22
-+
+ + 
 rev,

Check the test repo is created correctly